GSLBermuda
asked on
Need to modify application removal script
I'm using the script below to remove some apps like Groupwise and Novell Client. I need to modify it so that when prompted with the "Do you want to uninstall" it automatically selects yes. I don't want any user interaction with this script. I believe I need to use the /qn switch somewhere, but I'm not sure where?
Here is the script:
Option Explicit
Dim strComputer, strMSI, MSIapp, App, AppToRemove, objShell
strComputer = "."
set objShell = CreateObject("WScript.Shel l")
'========================= ========== =====
AppToRemove = "Groupwise"
'
strMSI = UninstallString(AppToRemov e)
If strMSI<>"" Then
wscript.echo strMSI
objShell.Run strMSI
End If
function UninstallString(strProduct Name)
dim strComputer, oReg, strKeyPath, arrSubKeys, subkey, x
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{ impersonat ionLevel=i mpersonate }!\\" & strComputer & "\root\default:StdRegProv" )
' Get array of subkeys under uninstall registry entry
strKeyPath = "SOFTWARE\microsoft\window s\currentv ersion\uni nstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
x=FindUninstallString(subk ey, strProductName)
if x<>"" then
if LCase(Left(x,7))="msiexec" then
' Check msiexec for parameters...
if InStr(1,x,"/I")>0 then x=Replace(x, "/I","/X")
if InStr(1,x,"/quiet")<1 then x=x & " /quiet"
if InStr(1,x,"/noreboot")<1 then x=x & " /noreboot"
end if
UninstallString=x
exit function
end if
Next
end function
function FindUninstallString(strKey , strProductName)
dim DisplayName, Publisher, UninstallString, search
On Error Resume Next
DisplayName=objShell.RegRe ad ("HKEY_LOCAL_MACHINE\SOFTW ARE\Micros oft\Window s\CurrentV ersion\Uni nstall\" & strKey & "\DisplayName")
Publisher=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTW ARE\Micros oft\Window s\CurrentV ersion\Uni nstall\" & strKey & "\Publisher")
UninstallString=objShell.R egRead ("HKEY_LOCAL_MACHINE\SOFTW ARE\Micros oft\Window s\CurrentV ersion\Uni nstall\" & strKey & "\UninstallString")
search = Instr(1, DisplayName, strProductName, 1)
' Get uninstall string
if search>0 Then
if UninstallString="" then UninstallString="MsiExec.e xe /X" & strKey
FindUninstallString = UninstallString
end if
end function
Here is the script:
Option Explicit
Dim strComputer, strMSI, MSIapp, App, AppToRemove, objShell
strComputer = "."
set objShell = CreateObject("WScript.Shel
'=========================
AppToRemove = "Groupwise"
'
strMSI = UninstallString(AppToRemov
If strMSI<>"" Then
wscript.echo strMSI
objShell.Run strMSI
End If
function UninstallString(strProduct
dim strComputer, oReg, strKeyPath, arrSubKeys, subkey, x
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{
' Get array of subkeys under uninstall registry entry
strKeyPath = "SOFTWARE\microsoft\window
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
x=FindUninstallString(subk
if x<>"" then
if LCase(Left(x,7))="msiexec"
' Check msiexec for parameters...
if InStr(1,x,"/I")>0 then x=Replace(x, "/I","/X")
if InStr(1,x,"/quiet")<1 then x=x & " /quiet"
if InStr(1,x,"/noreboot")<1 then x=x & " /noreboot"
end if
UninstallString=x
exit function
end if
Next
end function
function FindUninstallString(strKey
dim DisplayName, Publisher, UninstallString, search
On Error Resume Next
DisplayName=objShell.RegRe
Publisher=objShell.RegRead
UninstallString=objShell.R
search = Instr(1, DisplayName, strProductName, 1)
' Get uninstall string
if search>0 Then
if UninstallString="" then UninstallString="MsiExec.e
FindUninstallString = UninstallString
end if
end function
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.