RicohIT
asked on
Uninstall WebEx with VBS Script
Hi
I need a simple VBS script that uninstalls Webex from the computer silently. The command to uninstall it silently is as follows:
msiexec.exe /q /x "ptoolsni.msi"
Problem is that i am going to email this script to users on network so they can click it and get rid of webex. But users have different rights, some have admin rights and some doesnt. So how can i also add admin user and password encrypted so user wont be able to see that if he tries.
I need a simple VBS script that uninstalls Webex from the computer silently. The command to uninstall it silently is as follows:
msiexec.exe /q /x "ptoolsni.msi"
Problem is that i am going to email this script to users on network so they can click it and get rid of webex. But users have different rights, some have admin rights and some doesnt. So how can i also add admin user and password encrypted so user wont be able to see that if he tries.
i've added some logging to the script
const X64_UNINSTALL_REGISTRY = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
const X32_UNINSTALL_REGISTRY = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
TryUninstall "WebEx", X32_UNINSTALL_REGISTRY
Sub TryUninstall (program, RegistryUninstallKey)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\uninstall.log", ForWriting, True)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Wscript.Echo RegistryUninstallKey
oReg.EnumKey HKEY_LOCAL_MACHINE, RegistryUninstallKey, arrSubKeys
For Each subkey In arrSubKeys
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "DisplayName", displayName
if displayName = program then
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "UninstallString", strUninstall
if (strUninstall <> "") then
if LCase(Left(strUninstall,6))="msiexec" then
uninstallCmd = Replace(strUninstall, "/I{", "/X{") & " /q REMOVE=ALL" ' MSI installer
else
uninstallCmd = strUninstall & " /S /NCRC" 'assume NSIS installer
end if
Wscript.Echo uninstallCmd
WshShell.Run uninstallCmd, 0, true
end if
objTextFile.WriteLine(Trim(program) & " uninstalled.")
end if
Next
objTextFile.Close
End Sub
ASKER
Thanks for replying, but as i dont know anything about VBS i would like to ask u something. Am i suppose to paste it into notepad and save it as VBS and then just run it? or do i need to do some kind of modification? Webex which is installed on over 50 computers was installer thru SCCM, and i still believe u need admin rights to uninstall it. But still im gonna give it a try.
just copy and paste it in notepad and save it as .vbs
to run it from command line:
cscript thescript.vbs
installing via SCCM doesn't have any impact on the script as long as the installer file was .msi (windows installer) or nsis installer.
anyway, the uninstall string GUID in the registry is what makes the script works cause it doesn't depend on the installer file or the way the installer was built.
to run it from command line:
cscript thescript.vbs
installing via SCCM doesn't have any impact on the script as long as the installer file was .msi (windows installer) or nsis installer.
anyway, the uninstall string GUID in the registry is what makes the script works cause it doesn't depend on the installer file or the way the installer was built.
another thing,
you can run it from explorer:
right click-> open with- > Windows Based Script Host (see screenshot)
if you run it from command line, type the following:
cscript thescript.vbs > c:\thescript.log
then you can check the log file to see the result of operation.
Untitled.jpg
you can run it from explorer:
right click-> open with- > Windows Based Script Host (see screenshot)
if you run it from command line, type the following:
cscript thescript.vbs > c:\thescript.log
then you can check the log file to see the result of operation.
Untitled.jpg
ASKER
So ill have users just dubble click it and it will uninstall Webex on their computer regardless of their rights being admin or not. Hmmm, lets give it a try.
ASKER
sorry, took it from another script of mine.
change line 8 from:
Set objTextFile = objFSO.OpenTextFile ("c:\uninstall.log", ForWriting, True)
to:
Set objTextFile = objFSO.CreateTextFile ("c:\uninstall.log", ForWriting, True)
change line 8 from:
Set objTextFile = objFSO.OpenTextFile ("c:\uninstall.log", ForWriting, True)
to:
Set objTextFile = objFSO.CreateTextFile ("c:\uninstall.log", ForWriting, True)
here's an updated script for you:
const X64_UNINSTALL_REGISTRY = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
const X32_UNINSTALL_REGISTRY = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
TryUninstall "Acrobat.com", X32_UNINSTALL_REGISTRY
Sub TryUninstall (program, RegistryUninstallKey)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile ("c:\uninstall.log", 2, True)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumKey HKEY_LOCAL_MACHINE, RegistryUninstallKey, arrSubKeys
For Each subkey In arrSubKeys
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "DisplayName", displayName
if displayName = program then
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "UninstallString", strUninstall
if (strUninstall <> "") then
if LCase(Left(strUninstall,6))="msiexec" then
uninstallCmd = Replace(strUninstall, "/I{", "/X{") & " /q REMOVE=ALL" ' MSI installer
else
uninstallCmd = strUninstall & " /S /NCRC" 'assume NSIS installer
end if
WshShell.Run uninstallCmd, 0, true
end if
objTextFile.WriteLine(Trim(program) & " uninstalled.")
end if
Next
objTextFile.Close
End Sub
ASKER
remember that im using a user now with limited rights, and creating a file on C: would deffinetly not work. Is creating a log file neccessary?
actually no, and you can change it to temporary file such as c:\windows\temp
ASKER
i've updated the script.
what the error says in english?
what the error says in english?
ASKER
the object is not a collection
here's the upated script:
const HKEY_LOCAL_MACHINE = &H80000002
const X64_UNINSTALL_REGISTRY = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
const X32_UNINSTALL_REGISTRY = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
TryUninstall "Acrobat.com", X32_UNINSTALL_REGISTRY
Sub TryUninstall (program, RegistryUninstallKey)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile ("c:\uninstall.log", 2, True)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumKey HKEY_LOCAL_MACHINE, RegistryUninstallKey, arrSubKeys
For Each subkey In arrSubKeys
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "DisplayName", displayName
if displayName = program then
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "UninstallString", strUninstall
if (strUninstall <> "") then
if LCase(Left(strUninstall,6))="msiexec" then
uninstallCmd = Replace(strUninstall, "/I{", "/X{") & " /q REMOVE=ALL" ' MSI installer
else
uninstallCmd = strUninstall & " /S /NCRC" 'assume NSIS installer
end if
WshShell.Run uninstallCmd, 0, true
end if
objTextFile.WriteLine(Trim(program) & " uninstalled.")
end if
Next
objTextFile.Close
End Sub
ASKER
i get the same error, on line 15 character 2, Object is not a collection
Something wrong with this line i guess: For Each subkey In arrSubKeys
Something wrong with this line i guess: For Each subkey In arrSubKeys
can you post your script?
ASKER
const HKEY_LOCAL_MACHINE = &H80000002
const X64_UNINSTALL_REGISTRY = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
const X32_UNINSTALL_REGISTRY = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
TryUninstall "Acrobat.com", X32_UNINSTALL_REGISTRY
Sub TryUninstall (program, RegistryUninstallKey)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile ("c:\windows\temp\uninstall3.log", 2, True)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumKey HKEY_LOCAL_MACHINE, RegistryUninstallKey, arrSubKeys
For Each subkey In arrSubKeys
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "DisplayName", displayName
if displayName = program then
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "UninstallString", strUninstall
if (strUninstall <> "") then
if LCase(Left(strUninstall,6))="msiexec" then
uninstallCmd = Replace(strUninstall, "/I{", "/X{") & " /q REMOVE=ALL" ' MSI installer
else
uninstallCmd = strUninstall & " /S /NCRC" 'assume NSIS installer
end if
WshShell.Run uninstallCmd, 0, true
end if
objTextFile.WriteLine(Trim(program) & " uninstalled.")
end if
Next
objTextFile.Close
End Sub
try
const HKEY_LOCAL_MACHINE = &H80000002
const X64_UNINSTALL_REGISTRY = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
const X32_UNINSTALL_REGISTRY = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
TryUninstall "Acrobat.com", X32_UNINSTALL_REGISTRY
Sub TryUninstall (program, RegistryUninstallKey)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile ("c:\windows\temp\uninstall3.log", 2, True)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
if oReg.EnumKey(HKEY_LOCAL_MACHINE, RegistryUninstallKey, arrSubKeys) =0 then
For Each subkey In arrSubKeys
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "DisplayName", displayName
if displayName = program then
oReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "UninstallString", strUninstall
if (strUninstall <> "") then
if LCase(Left(strUninstall,6))="msiexec" then
uninstallCmd = Replace(strUninstall, "/I{", "/X{") & " /q REMOVE=ALL" ' MSI installer
else
uninstallCmd = strUninstall & " /S /NCRC" 'assume NSIS installer
end if
WshShell.Run uninstallCmd, 0, true
end if
objTextFile.WriteLine(Trim(program) & " uninstalled.")
end if
Next
end if
objTextFile.Close
End Sub
ASKER
i will try it tommowor and give u a reply. By the way the string i gave u for uninstalling the program was wrong. I have the right string at work and i will try it tommorow.
ASKER
Oki dude, i think iv solved the problem my self. I created a bat file for this and used lsrunas.exe to have bat file remember the password so it doesnt prompt for password every time you execute it. Password was written in plain text though, but i converted the bat file to exe file so people wont see the password by editing it. Im giving you the points because of your effort. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
found a solution myself, but thanks for the effort
Open in new window