calling vbscript from custom action
Hi,
I have writen a vbscript to remove some registry keys during uninstallation.It works fine when run noramlly but when i call it from a custom action (call VBScript from embedded code) it gives error 1720 script could not be executed.
Dim WshShell, bKey
Set WshShell = CreateObject("WScript.Shell")
Const HKLM = &H80000002
Dim strKey
Dim arrSubKeys()
Dim objReg
Dim strComputer
Dim abc
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKey = "Software\xyz"
objReg.EnumKey HKLM, strKey, arrSubKeys
'The next section will just go through the array to find the desired key.
For intI = 0 to UBound(arrSubKeys)
If arrSubKeys(intI) = "abc" Then
abc = arrSubKeys(intI)
End If
Next
If abc = "abc" and UBound(arrSubKeys) = 0 Then
WshShell.RegDelete "HKLM\Software\xyz\abc\"
WshShell.RegDelete "HKLM\Software\xyz\"
End If
If abc = "abc" and UBound(arrSubKeys) > 0 Then
WshShell.RegDelete "HKLM\Software\xyz\abc\"
End If
can anybody tell me how i can get this code to work from a custom action..looks like the Enumkey method is not being recognised..any
help would be greatly appreciated..Thanks in advance
I have writen a vbscript to remove some registry keys during uninstallation.It works fine when run noramlly but when i call it from a custom action (call VBScript from embedded code) it gives error 1720 script could not be executed.
Dim WshShell, bKey
Set WshShell = CreateObject("WScript.Shell")
Const HKLM = &H80000002
Dim strKey
Dim arrSubKeys()
Dim objReg
Dim strComputer
Dim abc
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKey = "Software\xyz"
objReg.EnumKey HKLM, strKey, arrSubKeys
'The next section will just go through the array to find the desired key.
For intI = 0 to UBound(arrSubKeys)
If arrSubKeys(intI) = "abc" Then
abc = arrSubKeys(intI)
End If
Next
If abc = "abc" and UBound(arrSubKeys) = 0 Then
WshShell.RegDelete "HKLM\Software\xyz\abc\"
WshShell.RegDelete "HKLM\Software\xyz\"
End If
If abc = "abc" and UBound(arrSubKeys) > 0 Then
WshShell.RegDelete "HKLM\Software\xyz\abc\"
End If
can anybody tell me how i can get this code to work from a custom action..looks like the Enumkey method is not being recognised..any
help would be greatly appreciated..Thanks in advance
0 Comments
[ + ] Show comments
Answers (10)
Please log in to answer
Posted by:
brenthunter2005
19 years ago
Posted by:
artiahc_elay
19 years ago
Posted by:
brenthunter2005
19 years ago
Posted by:
artiahc_elay
19 years ago
Hi brent,
This is my code that works fine..If u have any questions let me know
Set WshShell = CreateObject("WScript.Shell")
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\XYZ"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
msgbox "Subkeys under " _
& "HKEY_LOCAL_MACHINE\Software\XYZ"
'The next section will just go through the array to find the desired key.
If not IsNull(arrSubKeys) Then
For intI = 0 to UBound(arrSubKeys)
If arrSubKeys(intI) = "abc" Then
abc = arrSubKeys(intI)
End If
Next
If abc = "abc" and UBound(arrSubKeys) = 0 Then
WshShell.RegDelete "HKLM\Software\XYZ\abc\"
WshShell.RegDelete "HKLM\Software\XYZ\"
End If
If abc = "abc" and UBound(arrSubKeys) > 0 Then
WshShell.RegDelete "HKLM\Software\XYZ\abc\"
End If
End If
Thanks
Chaitra
This is my code that works fine..If u have any questions let me know
Set WshShell = CreateObject("WScript.Shell")
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\XYZ"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
msgbox "Subkeys under " _
& "HKEY_LOCAL_MACHINE\Software\XYZ"
'The next section will just go through the array to find the desired key.
If not IsNull(arrSubKeys) Then
For intI = 0 to UBound(arrSubKeys)
If arrSubKeys(intI) = "abc" Then
abc = arrSubKeys(intI)
End If
Next
If abc = "abc" and UBound(arrSubKeys) = 0 Then
WshShell.RegDelete "HKLM\Software\XYZ\abc\"
WshShell.RegDelete "HKLM\Software\XYZ\"
End If
If abc = "abc" and UBound(arrSubKeys) > 0 Then
WshShell.RegDelete "HKLM\Software\XYZ\abc\"
End If
End If
Thanks
Chaitra
Posted by:
challa_praveena
19 years ago
Posted by:
noodles187
18 years ago
G
Hi Brett,
I have a similar issue with the following script, can you tell me where it's going wrong?
Dim WSHShell
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegDelete "HKLM\SOFTWARE\Figtree Systems Pty Ltd\Figtree Enhancement 18.5\18.5\"
WSHShell.RegDelete "HKLM\SOFTWARE\Figtree Systems Pty Ltd\Figtree Enhancement 18.5\"
WSHShell.RegDelete "HKLM\SOFTWARE\Figtree Systems Pty Ltd\"
set WSHShell = nothing
Posted by:
brenthunter2005
18 years ago
The script looks fine to me.
Your issue might be to do with the sequence location in the MSI package.
If your custom action is placed after the InstallFinalize action then it needs to be run in the Immediate Execution.
If your custom action is placed between then InstallInitalize and InstallFinalize actions then it needs to be run in the Deferred Execution.
Your issue might be to do with the sequence location in the MSI package.
If your custom action is placed after the InstallFinalize action then it needs to be run in the Immediate Execution.
If your custom action is placed between then InstallInitalize and InstallFinalize actions then it needs to be run in the Deferred Execution.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.