Using WMIC in a batch file to uninstall a program
17,193
Try using:
@Echo Off
Title Forcepoint DLP Endpoint
Echo Forcepoint DLP Endpoint
WMIC Product Where "Name='Forcepoint DLP Endpoint'" Call Uninstall /NoInteractive
If that doesn't work then perhaps this might:
@Echo Off
Title Forcepoint DLP Endpoint
Echo Forcepoint DLP Endpoint
Echo Y|WMIC Product Where "Name='Forcepoint DLP Endpoint'" Call Uninstall
If the Echo Y|
doesn't work then you may just have to remove it and accept the yes/no prompt or find another method of uninstall.
Comments
-
FRALEWHALE almost 2 years
I am writing a script to uninstall a program. I am utilizing WMIC to do this. When I run the script, it stops immediately after the wMIC command is run. When run it manually everything works fine. My script looks like this:
@echo off title Forcepoint DLP Endpoint Echo Forcepoint DLP Endpoint wmic product where name="Forcepoint DLP Endpoint" call uninstall /nointeractive
What should I be added after "WMIC" in order to continue the script?
This script when entered manually worked:
wmic product where name="Forcepoint DLP Endpoint" call uninstall Y
-
npocmaka about 6 yearsDoes wmic have
/nointeractive
global switch? -
Compo about 6 yearsI wasn't aware you could use parameters with the
Uninstall
method,WMIC Product Call /?
. What happens if you run it without the/nointeractive
parameter -
FRALEWHALE about 6 years@Compo It prompts you, asking if you are sure you want to uninstall "X" program. You can either enter Y or N. Entering Y worked normally.
-
Compo about 6 yearsAnd when you enter
Y
, does the script continue. If not what is the next line you are expecting should run, because you didn't include it in your snippet, despite it being relevant to your question? -
npocmaka about 6 yearstry with
echo Y|wmic product ...
. Tough it should not ask you shuch a thing. -
FRALEWHALE about 6 years@Compo when I run the script. After the WMIC it ends up with a wmic:root\cli> when it should just run the WMIC command and then run the "product where name="PROGRAM TO BE UNINSTALLED" call uninstall /nointeractive" command.
-
Compo about 6 yearsPerhaps you can just edit your question to provide the command with the products real
name
string, and yourwmic:root\cli>
is because yourwmic
command should be on the same line asproduct
separated by a space. -
FRALEWHALE about 6 years@Compo edited to include the real name, along with the command that actually worked.
-
-
FRALEWHALE about 6 yearsThe second method worked on the program I was testing. I ran it as an admin, it popped up, ran the script, replied with a success and then closed the script. I can't imagine why this would not work on the program I am actually trying to uninstall.
-
Compo about 6 years@FRALEWHALE, you would have to contact the developer to verify the uninstallation process for that particular product. There's no single uninstall routine you can use for all products. Perhaps checking the registry for it's official UninstallString may help you.
-
FRALEWHALE about 6 yearsI had planned on checking the registry to confirm that it was in fact uninstalled.