/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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   [ - ] Hide Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity

Answers

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
Answered 12/25/2011 by: mayur_mak
Senior Purple Belt

Please log in to comment
0
Thanks Mayur. It worked for me.
Answered 12/27/2011 by: sanhivi
Third Degree Green Belt

Please log in to comment
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
Answered 12/27/2011 by: sanhivi
Third Degree Green Belt

Please log in to comment
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
Answered 12/27/2011 by: mahendraKumar
Senior Yellow Belt

Please log in to comment
0
Thanks Mahendrakumar.....

Regards,
Sanhivi
Answered 01/03/2012 by: sanhivi
Third Degree Green Belt

Please log in to comment