How to Uninstall a Program Using Cmd in Windows 10
- Home
- Windows
- General Windows
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 ?
- ROM
- CPU
- RAM
- GPU
12 Replies
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.
https://devblogs.microsoft.com/scripting/use-powershell-to-quickly-find-installed-software/
https://devblogs.microsoft.com/scripting/use-powershell-to-find-and-uninstall-software/
Evan7191 wrote:
Win32_Product is very inefficient.
More info on that:
https://gregramsey.net/2012/02/20/win32_product-is-evil/
I echo everything Evan said.
I tried the code as explained in this KB: https://devblogs.microsoft.com/scripting/use-powershell-to-quickly-find-installed-software/ " to no avail, still cannot get all programs but the one with msi installer !
awsayad wrote:
I tried the code as explained in this KB: https://devblogs.microsoft.com/scripting/use-powershell-to-quickly-find-installed-software/ " to no avail, still cannot get all programs but the one with msi installer !
Can you provide an example of some of the applications that you want to uninstall?
awsayad wrote:
I tried the code as explained in this KB: https://devblogs.microsoft.com/scripting/use-powershell-to-quickly-find-installed-software/ " to no avail, still cannot get all programs but the one with msi installer !
Also, most of the code in that link is about listing installed software rather than removing it. I posted it as evidence that Win32_Product is inefficient.
The second link that I posted has more examples for uninstalling software. Here it is again:
https://devblogs.microsoft.com/scripting/use-powershell-to-find-and-uninstall-software/
The ones I was testing on were: WireShark 2.4.12 64 bit, TreeSize Free V4.2.2 and NotePad++ (32-bit x86)
yes, I am aware of that, I was hoping if I can get a list of these applications then I can actually remove them using the script but they still not showing up. try install TreeSize or WireShark and see if the code listed will return these application !
I'm reg edit browse to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall.
Find the key the contains the software you want to uninstall
There will be a value for the uninstall string that is what you run
Check out: Computer Management Utility by Spiceworks user Stuart Barrett.
I know it's not a script you can run, but it does feature a "silent uninstall" button for items found in their add/remove programs list. I've successfully used it to silently remove software from user's PCs without interrupting them.
Hope this helps!
jackofalltech wrote:
I'm reg edit browse to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall.
Find the key the contains the software you want to uninstall
There will be a value for the uninstall string that is what you run
THIS. And look at https://community.spiceworks.com/topic/647939-show-all-programs-using-wmic-command. That's the only places that groups all the installers, MSI and non-MSI, into one location.
This topic has been locked by an administrator and is no longer open for commenting.
To continue this discussion, please ask a new question.
How to Uninstall a Program Using Cmd in Windows 10
Source: https://community.spiceworks.com/topic/2195742-how-to-uninstall-a-program-using-cmd-or-power-shell