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.comHow do i uninstall a program using cmd in Recovery?
Uninstall program through CMD?
Script to uninstall program
Windows 10: How can you uninstall a program when the command prompt is blocked?
Videos
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 ?
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...
Hi IIIGeneralII
This problem has been solved by me, i just forgot that the support ticket is still active :b
You can uninstall the program by breaking it, simply use the following command in the recovery cmd
cd C:
Note: depending on which drive you install windows on, it might be D: or something else
cd Program Files
After that use dir to locate the avast file
If you didn’t find it use cd program files (x86) instead
Note its important to check on ehich folder did avast install on
Search on the internet and find out
After that
del avast
It will say “are you sure? (Y/N)?”
Type y and enter
Use cd avast to make sure that all files are deleted
Then use dir
If not all of them are deleted
Use del (something like avast.exe and etc) on all of the files.
Restart your PC/laptop and boot into it
For driver issues and boot looping
Check other topics on them
system restore does not work in my case and when trying to use wmic, product returns an invalid class error. Neither of these are a solution for me.
The issue is trying to download avast, the driver files were corrupted causing the BSOD. It is now in a boot loop and the repair nor the system restore will work. They return errors. Checking the logs, they point back to AVAST files. Now I am trying to just remove AVAST since this all happened when I started to download it and the corrupted files all seem to be due to AVAST. I figured the easiest thing should have been to uninstall via the CMD, but wmic does not work as when I type product or product get name, it returns
Node - MININT-JBIHR0D
ERROR:
Description - Invalid class
Every program that properly installs itself according to Microsoft's guidelines makes a registry entry in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall. Usually, the key for the program will be its GUID, or else the name of the program. Within that key will be an entry called UninstallString. This contains the command to execute to uninstall the program.
If you already know ahead of time what you will be uninstalling, it should be easy enough to just put that in your batch file. It gets tricky when you try to automate that process though. You can use the reg command to get data from the registry, but it returns a lot of text around the actual value of a given key, making it hard to use. You may want to experiment with using VBscript or PowerShell, as they have better options for getting data from the registry into a variable.
You can invoke the correct uninstaller without knowing the GUID, etc. by using WMIC.
To see a list of the names of the programs as known internally by Windows:
wmic product get name
Look for your product name. It probably matches the one listed in the "Programs and Features" control panel, but not always.
Then you can use
wmic product where name="_my_product_name" call uninstall
to perform the uninstall, which AFAIK should be silent (it has been in my experience, but try it before you bet the farm on that. Silence may depend on how your installer/uninstaller was built).
See here for more:
- WMIC: the best command line tool you've never used (overview of WMIC with lots of cool commands described)
- Windows: Uninstall an Application from the Command Line (the specific recipe)
There's also reference documentation for WMIC on microsoft.com.
I have a program that is acting like a virus, can’t uninstall through apps or through the programs in control panel. Has no .msi file. How do I do it?
Hello all, Not directly power shell but this is the closest sub I could find that may be able to help. I am trying to uninstall a program and clean up afterwards by deleting the associated folders, but running into issues when combining all the commands as a script.
What I have so far is:
-
@ECHO OFF
-
Net stop tripwireAxonAgent
-
Wmic
-
product where name="Axon Agent" call uninstall /nointeractive
-
Quit <=(here is where I have the issue)
-
RMDIR /s /q "C:\ProgramData \Tripwire\Agent"
-
Pause
My main issue is after the product uninstall via WMIC, it will not exit that prompt and remains inside the subsection for it. I’ve tried “quit” “exit” and CD back to the default c:\windows but any command I enter says “syntax error” and just puts the command to delete the directory on screen and freezes the screen.
If I run the commands by themselves, there is no issue and it completes without a problem.
What am I missing / not doing properly. Any help is appreciated.
Also, for reference, I used WMIC to uninstall the program because the MSI the vendor was telling me to use was consistently giving me errors saying “ a product is already installed. You cannot install this version.” or I would get an error saying “ the product is not installed”
Would it be easier to switch this over to power shell to complete the task? I did not originally use power shell because the vendor said there may be issues when using it.
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?
When you install a program in Windows a registry key for its uninstallation is created holding several values, among them is the UninstallString value which is the command line the Add or remove programs uses when you click Remove.
The parent key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
And these UninstallStrings usually have the following format:
MsiExec.exe /I{0826F9E4-787E-481D-83E0-BC6A57B056D5}
In order to acomplish what you are trying to do you will have to create a RegistryKey object, read the UninstallString value for the application you want to remove and run the command line.
More info here.
You can use revo uninstaller, not for its uninstallation features, but for its main view, that shows the registered uninstall string of your application.
But it's only a starting point. Every setup engine can have its own uninstall string. You have to find the correct one, if you are lucky enough for it to exists (try /quiet, /passive, etc. until you find the correct one).