Search code examples
batch-filewmic

Using WMIC in a batch file to uninstall a program


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

Solution

  • 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.