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
0 Comments   [ + ] Show 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.

Answers

0
When this script errors on your computer, you should be able to check the Application Event Log and it will tell you which line of code has the error.
Answered 03/23/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
i checked the logfile says vbscript runtime error: invalid procedure call or argument: 'EnumKey'
Answered 03/23/2005 by: artiahc_elay
Senior Yellow Belt

Please log in to comment
0
I've just done this in a MSI CA and it works fine for me, but I'm doing it all with full admin rights.

Try adding the following line of code after your "Set objReg=GetObject..........."
If objReg Is Nothing then msgbox "objReg is not set to anything!"
Answered 03/23/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
Thanks Brent its working fine just made a few changes
Answered 03/23/2005 by: artiahc_elay
Senior Yellow Belt

Please log in to comment
0
Can you post your solution so that others will know please?
Answered 03/24/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
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
Answered 03/24/2005 by: artiahc_elay
Senior Yellow Belt

Please log in to comment
0
Nice one.
Answered 03/29/2005 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
Hi,

I am new to this forum- I am in need of urgent help- I have to create an MSI file and call and run a vbscript from that MSI file and I have no clue how to do it in .net.


any help is gr8tly appreciated.


thanks

rgds
pivi
Answered 04/04/2005 by: challa_praveena
Yellow Belt

Please log in to comment
0
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
Answered 09/22/2006 by: noodles187
Orange Belt

Please log in to comment
0
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.
Answered 09/22/2006 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
Answer this question or Comment on this question for clarity