I'd like to create a script that silently uninstalls certain programs (i.e., the ones that no one ever uses but they come pre-installed).
I know there's a step to uninstall by GUID but where do i get these GUIDs and are they different for each version of a product?
Any other tips on creating this type of script?
You can get the uninstall command string from the Add/Remove Programs in the Machine Audit page.
Would the uninstall strings vary from computer to computer (i.e., win7 vs. xp or different versions of program)?
What i tried first was a program from symantec called SepPrep. It uses keywords to search through add/remove and uninstall programs. Couldnt get it to work properly though...
I don't think they vary from computer to computer (as long as the OS is the same) but they for sure vary from version to version.
Have you looked at this product? http://pcdecrapifier.com/
This looks pretty cool but can it be used in a script and run silently.
I'd like to preset all the unwanted programs and if any are detected it uninstalls them. You know if thats possible? I'm willing to buy the commercial version if necessary
you could also write a scirpt to use wmic to call the uninstall string for everything you're looking to remove. So once you've identifed what you're looking to remove you could use something like this via execute shell command
wmic product where name='programe to remove' call uninstall
If you wanted to add less granulaterity to it b/c maybe the versions have different names you could use the LIKE command:
wmic product where (name like '%product to remove%') call uninstall
the % is a wild card
I hope this helps.
also if you wanted to use a vbscript you could try this one. I cooked it up a while ago and use'd it before I learned about wmic. The script below should be saved as a vbscript and will require 2 arguments passed to it, the 1st is the name of the app from the display key in the uninstall registry. the 2nd is the version number. I recommend using 0 (zero) to cover all versions. This script will also spit back an echo for removed, etc if you wanted to capture the input for reporting via the "execute shell command capture output" procedure in kasyea. if you need help with it just let me know. :
'Created By danrche'run with command line arguments
'to get app string match
'and version match or less then
'app_ver_check.vbs "adobe reader" 1001
'that should check for adobe reader
'versions are upto date for 10
Set oArgs = WScript.Arguments
iCount = WScript.Arguments.Count
sCmdLine0 = WScript.Arguments.Item(0)
iCmdLine1 = WScript.Arguments.Item(1)
If iCount <> 2 Then
WScript.Echo "The correct usage is 'App_Ver_Check.vbs 'app' 'version''"
ElseIf IsNumeric(iCmdLine1) <> True Then
WScript.Echo "The version number should be of a numerical value with no '' or ."
sfindapp sCmdLine0, iCmdLine1
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
If instr(1, unistString, "msiexec", 1) = 1 Then
WshShell.Run "msiexec.exe /x" & subkey & " /qn /promptrestart", True
If iFound = 0 Then logfile(sAPP + " not found")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile("C:\temp\app_unist.log", ForWriting, True)
The wmic command seems to work and its so simple!!
Thanks, this is so much easier than using an .exe file that i need to customize
Thanks for the VB script but as long as the command line works ill use that
happy to help. I don't blame you about the vbscript, but like i said, it's what I made before I knew about the wmic tool.
I ran it for one program and it worked but now I'm trying with others and keep getting "no instance(s) Available."
I'm looking at the add/remove so i know the programs exist. I'm trying with and without wildcard values and its not finding the programs. Any tips?
check it on the machine, It uses win32_product class ( msdn.microsoft.com/.../aa394378%28v=vs.85%29.aspx) so you can also use a cim tool from MS to verify it as well. What's the product's name? Apperantly Win32_Product Class only shows products installed by windows installer. For instance, I have a flash player script for ver 11, but wmic doesn't pick up that it's installed as a product ::: WMIC product list brief << this shows me all products listed for wmi... is the product you're looking for in the list?
the vbscript I provided will show the insatll as well as version though. Sorry about not telling you about the "Only shows from windows installer" I actually just found that out researching your issue and troubleshooting it on my test box. :(
After researching this a bit more I've found that the add/remove list you see in the control panel is derivied from the uninstall reg key. So the script I provided would be a better way to find a list via add/remove. it's still fairly simple to run the script against a remote PC. your syntax would be :
execute shell command : c:\location for agent temp\app_echo.vbs "adobe flash" 0
this will put a log file in c:\temp\app_echo.log as well as echo back the results (if you wanted to use the execute shell command get results to variable).
the script treat's the string as wild cards and searches anything that matches. The version can be specific if you're looking to target a specific version, otherwise use 0 for any version to uninstall.
I hope this helps. sorry again about the "Got ya!" for the WMIC.... I learned something today too on that one.
Is the any way to make it run silently?
are you talking about the script? the vbscript should put in the /qn which runs silently, but will call the uninstall string if it's not an msi uninstaller. IF that's the case, then chances are the exe will need some sort of special switch to uninstall silently. I can modify that peice to add a /quiet into the .exe uninstall string which would pass it, but that would only work as long as it's supported within the app it's self. What's the app your trying to remove, maybe I can figure out a way to silently remove it using the wmi tools or the regkey script I posted.