Using WMIC in a batch file to uninstall a program

醉酒当歌 提交于 2020-01-23 16:22:42

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/48527499/using-wmic-in-a-batch-file-to-uninstall-a-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!