It's really strange the script works fine if I double click on it, but if I call it from say an email shortcut I sent to my colleuges or shell run it from my other program, it throws the error:
Object not a collection
It fails on this line For Each subkey In arrSubKeys after objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
Here is the important part of the code, I removed the other stuff
Object not a collection
It fails on this line For Each subkey In arrSubKeys after objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
Here is the important part of the code, I removed the other stuff
vb Code:
Set shl = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Shell.Application") const AppName = "Helpdesk Toolkit" const HKEY_LOCAL_MACHINE = &H80000002 'Find Uninstall GUID Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products" objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each subkey In arrSubKeys InstalledAppName = "" On Error Resume Next InstalledAppName = shl.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\InstallProperties\DisplayName") If Err.Number <> 0 Then End If On Error Goto 0 If InStr(InstalledAppName, AppName) > 0 then RawGUID = "" GUID = "" RawGUID = shl.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\InstallProperties\UninstallString") GUID = Mid(RawGUID, instr(RawGUID, "{"), 38) If GUID<>"" then ' Found matching GUID, removing... msgbox(GUID) Exit For End If End If Next