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.

Share:
17,193
FRALEWHALE
Author by

FRALEWHALE

I needed to fill this in to get a badge.

Updated on June 14, 2022

Comments

  • FRALEWHALE
    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
      npocmaka about 6 years
      Does wmic have /nointeractive global switch?
    • Compo
      Compo about 6 years
      I 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
      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
      Compo about 6 years
      And 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
      npocmaka about 6 years
      try with echo Y|wmic product ... . Tough it should not ask you shuch a thing.
    • FRALEWHALE
      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
      Compo about 6 years
      Perhaps you can just edit your question to provide the command with the products real name string, and your wmic:root\cli> is because your wmic command should be on the same line as product separated by a space.
    • FRALEWHALE
      FRALEWHALE about 6 years
      @Compo edited to include the real name, along with the command that actually worked.
  • FRALEWHALE
    FRALEWHALE about 6 years
    The 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
    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
    FRALEWHALE about 6 years
    I had planned on checking the registry to confirm that it was in fact uninstalled.