/build/static/layout/Breadcrumb_cap_w.png

Require help in deleting registry value

Hi Everybody,

Can any body give me the script to delete the registry value.

I am having below key and value.

Key Path Name Value
HKCU\Software\ABC\ C:\Program Files\XYZ\a.xla NULL

I have to delete "C:\Program Files\XYZ\a.xla".

I have used the below script to delete the above value.

On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")

PrgFiles=WshShell.ExpandEnvironmentStrings("%ProgramFiles%")

strKeyPath = PrgFiles & "\XYz\a.xla"

KeyName1 = "HKEY_CURRENT_USER\Software\ABC\" & strkeypath

WshShell.RegDelete KeyName1

But this is not working. Can any body help me on this.

Thanks
Sanhivi

0 Comments   [ + ] Show comments

Answers (5)

Posted by: mayur_mak 12 years ago
Senior Purple Belt
0
@sanhivi

u can c if the below script works for u

const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\ABC"
strDWORDValueName = "C:\Program Files\XYZ\a.xla"
'strExpandedStringValueName = "Expanded String Value Name"
'strMultiStringValueName = "Multi String Value Name"
'strStringValueName = "String Value Name"

oReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,strDWORDValueName
'oReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,strExpandedStringValueName
'oReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,strMultiStringValueName
'oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName

regards,
Mayur
Posted by: sanhivi 12 years ago
Third Degree Green Belt
0
Thanks Mayur. It worked for me.
Posted by: sanhivi 12 years ago
Third Degree Green Belt
0
I require the same script to delete for each and every user. Above script only works for current user.
During installation time of my msi only i have to delete those current user registries from each and every user.

Can any body help me on this.

Regards,
Sanhivi
Posted by: mahendraKumar 12 years ago
Senior Yellow Belt
0
check this script ....

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
struserkey= "Software\ABC"
strDWORDValueName = "C:\Program Files\XYZ\a.xla"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

For Each objSubkey In arrSubkeys
strtargetkey = objSubkey & "\" & struserkey
oReg.DeleteValue HKEY_USERS,strtargetkey,strDWORDValueName

Next
Posted by: sanhivi 12 years ago
Third Degree Green Belt
0
Thanks Mahendrakumar.....

Regards,
Sanhivi
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ