Paradoxis
Paradoxis

Reputation: 4708

Prevent reboot when uninstalling a package using wmic

I'm currently writing a script that has to uninstall a program from lots of computers at once, the only place I could find information on how to do it for this specific program is by using wmic, however every time I run the command the machine does a hard reboot.

Is there a way (using wmic), to prevent a script from rebooting afer uninstalling a package? This is the command I'm currently using (on Windows 10)

wmic product where name="<application name>" call uninstall /nointeractive

Thank you for your help

Upvotes: 2

Views: 16239

Answers (2)

james widjaja
james widjaja

Reputation: 11

It probably depends on the specific uninstall procedure as some vendors may force an immediate restart while others give a short time for an abort to work. MrGoodTimes answer did not work for me but I found out that putting this before his code worked.

shutdown -s -t 180

Apparently, if there is already a shutdown in progress, the immediate shutdown will not be executed, giving time for an abort.

Upvotes: 1

MrGoodTimes
MrGoodTimes

Reputation: 31

I have found a solutions that has worked for me and seeing as how Google has only yielded me that same results as above I hope this helps.

echo product where name="APPLICATION NAME" call uninstall /nointeractive|wmic && shutdown /a

this allows the uninstallation to occur and then immediately aborts the shutdown/restart that the uninstall schedules.

Upvotes: 3

Related Questions