Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Uninstall Script Question - PLEASE HELP!!!

Status
Not open for further replies.

vbscript777

Technical User
Joined
Oct 14, 2009
Messages
1
Location
GB
Hi Guys,

With the WMI Query, we know that we can list out all installed applications.
But what it will list out only folders with install unique id (e.g. {07287123-B8AC-41CE-8346-3D777245C35B}) under
HKLM\SOFTWARE\Microsoft\Windows\Currentversion\uninstall\

If a folder is named with alphabetical name like "AI RoboForm", it will not be listed out by the WMI query.
Hence I can't really uninstall it with wmi switch.

anyone knows how to do this?
Please help. I'm pulling hair out...& i got not much left...
Cheers
 
WMI will only show you those applications installed via an MSI so if you need something to perform an uninstall of applications installed with a different installer you will need to have you script/app look in the registry and pull out the pertinent information.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
use WMI EnumKeys on the uninstall registry area, you can then do a string match on one of the subkeys string values, say DisplayName, you can then pull out the real uninstall command from the registry
 
Dim refRegObject, strKeyPath, arrKeys, i
Dim WshShell, strTemp, intReturn
Const HKLM = &H80000002
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
intError = 1
Set refRegObject = GetObject("Winmgmts:root\default:StdRegProv")
Set WshShell = CreateObject("Wscript.Shell")
If refRegObject.EnumKey(HKLM, strKeyPath, arrKeys) = 0 Then
For i = 0 to UBound(arrKeys)
'Wscript.Echo "HKLM\" & strKeyPath & "\" & arrKeys(i)
strTemp = ""
On Error Resume Next
strTemp = WshShell.RegRead("HKLM\" & strKeyPath & "\" & arrKeys(i) & "\DisplayName")
On Error Goto 0
'KPPAgentServiceSetup
'Wscript.Echo strTemp
If strTemp = "change_me_please" Then
strTemp = WshShell.RegRead("HKLM\" & strKeyPath & "\" & arrKeys(i) & "\UninstallString")
'Wscript.Echo strTemp
If InStr(strTemp, "/I") Then
strTemp = Replace(strTemp, "/I", "/X")
strTemp = strTemp & " /qb"
'Wscript.Echo strTemp
intReturn = WshShell.Run(strTemp, 1, True)
If intReturn <> 0 Then
intError = intReturn
Else
intError = 0
End If
End If
End If
Next
End If
Set WshShell = Nothing
Set refRegObject = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top