Thanks for the script!
I've updated it to also remove 32bit apps on 64bit machines, create a new instance for each uninstall and not restart. It's great for MSI's.. but non-MSI uninstallstrings, particularly ones with extra spaces such as Norton Internet Security are still an intermittent issue.
PC Decrapifier commercial version seems to be the most reliable option for now.
------
Set oArgs = WScript.Arguments
iCount = WScript.Arguments.Count
Set oShell = CreateObject("WScript.Shell")
If iCount = 1 Then
sCmdLine0 = WScript.Arguments.Item(0)
If instr(1, sCmdLine0, "/help", 1) = 1 OR instr(1,sCmdLine0,"/?",1) = 1 OR instr(1,sCmdLine0,"-?",1) =1 OR instr(1,sCmdLine0,"-help",1)=1 Then
wscript.echo "cscript app_uninst.vbs <app name> <version number>"
Wscript.echo "the allowed switches are /? -? /help -help"
else
sfindapp sCmdLine0, 0
end if
elseif iCount = 2 Then
sCmdLine0 = WScript.Arguments.Item(0)
iCmdLine1 = WScript.Arguments.Item(1)
If IsNumeric(iCmdLine1) <> True Then
WScript.Echo "The version number should be of a numerical value with no '' or ." & vbcrlf
wscript.echo "cscript app_uninst.vbs <app name> <version number>"
Wscript.echo "the allowed switches are /? -? /help -help"
else
sfindapp sCmdLine0, iCmdLine1
end if
elseif iCount > 2 Then
wscript.echo "Too many arguments specified" & vbcrlf
wscript.echo "cscript app_uninst.vbs <app name> <version number>"
Wscript.echo "the allowed switches are /? -? /help -help"
end if
Sub sfindapp(sAPP, iVersion)
On Error Resume Next
iFound = 0 'place holder if not found
Const HKEY_LOCAL_MACHINE = &H80000002
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("Wscript.Network")
Set oReg = GetObject("winmgmts:\\" & WshNetwork.ComputerName & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
disHolder = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" _
& subkey & "\DisplayName")
unistString = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" _
& subkey & "\UninstallString")
If instr(1, disHolder, sAPP, 1) = 1 Then
iFound = 1
logfile(sAPP)
logfile(disHolder)
logfile(unistString)
Wscript.Echo unistString
If instr(1, unistString, "msiexec", 1) = 1 Then
Wscript.echo "msiexec.exe /x " & subkey & " /qn /norestart REBOOT=ReallySuppress"
oShell.Run "msiexec.exe /x " & subkey & " /qn /norestart REBOOT=ReallySuppress", 1, True
Else
WshShell.Run unistString, 1, True
End If
End If
Next
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
disHolder = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" _
& subkey & "\DisplayName")
unistString = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" _
& subkey & "\UninstallString")
If instr(1, disHolder, sAPP, 1) = 1 Then
iFound = 1
Wscript.Echo unistString
logfile(sAPP)
logfile(disHolder)
logfile(unistString)
If instr(1, unistString, "msiexec", 1) = 1 Then
Wscript.echo "%systemroot%\syswow64\msiexec.exe /x " & subkey & " /qn /norestart REBOOT=ReallySuppress"
oShell.Run "%systemroot%\syswow64\msiexec.exe /x " & subkey & " /qn /norestart REBOOT=ReallySuppress", 1, True
Else
oShell.Run unistString
End If
End If
Next
If iFound = 0 Then logfile(sAPP + " not found")
End Sub
Function logfile(text)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile("C:\temp\app_unist.log", ForAppending, True)
f.WriteLine text
f.close
End Function