I need to use a script with either CMD or Power Shell to uninstall a program from a windows machine.
To be clear , I already know how to use the “wmic” & "Get-WmiObject -Class Win32_Product ", what I am looking for is how to remove the programs listed under Programs & Feature in control panel but doesn’t show up when using WMIC (Product Get Name) or (Get-WmiObject -Class Win32_Product) commands.
I can use these script easily:
1. CMD:
wmic
product get name
product where name=“program name” call uninstall
2. Power Shell:
$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match “Software Name” } >> $app.Uninstall()
Both scripts above helped me remove specific programs only, but the list I have under control panel still have lots of other applications that I am hoping to use similar script to remove them.
Any idea / suggestion is highly appreciated ?
Answer from awsayad on community.spiceworks.comI need to use a script with either CMD or Power Shell to uninstall a program from a windows machine.
To be clear , I already know how to use the “wmic” & "Get-WmiObject -Class Win32_Product ", what I am looking for is how to remove the programs listed under Programs & Feature in control panel but doesn’t show up when using WMIC (Product Get Name) or (Get-WmiObject -Class Win32_Product) commands.
I can use these script easily:
1. CMD:
wmic
product get name
product where name=“program name” call uninstall
2. Power Shell:
$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match “Software Name” } >> $app.Uninstall()
Both scripts above helped me remove specific programs only, but the list I have under control panel still have lots of other applications that I am hoping to use similar script to remove them.
Any idea / suggestion is highly appreciated ?
If the application was installed by MSI, and if you know the GUID, you can use msiexec to uninstall the application. That is the most efficient way, provided that the prerequisites are true.
Win32_Product is very inefficient.
Scripting Blog [archived] – 13 Nov 11
Use PowerShell to Quickly Find Installed Software - Scripting Blog [archived]
Summary: Learn how to use Windows PowerShell to quickly find installed software on local and remote computers. Microsoft Scripting Guy Ed Wilson here. Guest Blogger Weekend concludes with Marc Carter. The Scripting Wife and I were lucky enough...
Scripting Blog [archived] – 14 Dec 11
Use PowerShell to Find and Uninstall Software - Scripting Blog [archived]
Summary: Learn how to use Windows PowerShell to get software installation locations, and to uninstall software from remote computers. Hey, Scripting Guy! We have a dumb application that we have to use at work. The company has released a new version...
Uninstall software remotely using the command line - Software & Applications - Spiceworks Community
Windows 10: How can you uninstall a program when the command prompt is blocked?
batch file - Is there any Windows command to uninstall an application? - Stack Overflow
Script to uninstall program
Videos
On one of my client PCs, I had something called PowerPDF installed. I opened up my command prompt as Administrator, typed in appwiz.cpl to open up the Programs list. I then selected PowerPDF, then Uninstall/Change. At that moment, a command prompt window popped up telling me that access is denied.
A bit about our setup with respect to the issue...
Command prompt can be searched for in the Windows search bar. It will also display the opens Open, Run as Administrator nd Open File Location. If a user clicks 'Open', the command prompt will run, but show an access denied message. If 'Run as Administrator' is selected, the user is prompted for a Username and Password, which must be the Admin user.
I'm going to guess what's going on, is that the Uninstall script of the app is just attempting to run Command Prompt without Administrative Privileges, thus the uninstaller is getting blocked. How it got installed in the first place is beyond me.
Anyways, how can I uninstall an app with this problem?
You can get some clues as to where an application lives, by looking at where it's uninstaller is located.
Windows stores the list of uninstaller locations in the registry. You can use Regedit to go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall.
That registry key contains a whole lot of sub-keys with GUID names (big long strings of seemingly random letters and numbers). Use Regedit's search function and set it to look for the name of your program as it appears in the "programs and features" list of installed programs. (Un-tick keys and values and just leave data ticked).
Once you find the right sub-key, you'll see a bunch of values for your program. One of them will be called "UninstallString" and may point to the executable or DLL that is used to uninstall the software (or might pass a file location as a parameter to MSIexec or RunDLL). Depending on where the application's uninstaller lives, that information might give you the clue you need to find the rest of the application.
There are other bits of information in the registry that can help you too - See more info from Microsoft at https://msdn.microsoft.com/en-us/library/aa372105(v=vs.85).aspx
Typically programs that don't list an install location will have installed themselves in a number of places around your disk though, so it's best to use the uninstaller if you can.
Go to control panel --> Right click on the Control panel grid header --> Select More --> and check the location option.
Now the program location shows up in the control panel.