Uninstall Apps Remotely Through Command Line



Uninstall Apps Remotely Through Command Line

WMIC (Windows Management Instrumentation Command Line) is a powerful tool that often does not look much utilize due to the deficiency of (simple accessible) available documentation. More info can be get on WMIC here: technet.microsoft.com/en-us/library/bb742610.aspx. Few large alternate and switches choices can be got here: www.microsoft.com/resources/documentation/ windows/xp/all/proddocs/en-us/wmic_overview.mspx. We shall be using WMIC with domains admin credential to crawl via nodes list (PCs / Laptops) and uninstall program example without interrupting the users.



First Step into WMIC


One of the good feature of WMIC is that it can be execute from any available machines. With our admin commands shells, we are going to input the WMIC commands preceded by input. (Note: We could have transitioned into WMIC straightly from the execute as commands.... this just occurrent out the step)

Load up the command shell with proper permission of access


Though WMIC instructions can be provided suitable credential prior to operations, it is typically best practices to confront clear text password typing (who is that sounding over our shoulders;)). We shall execute the run as command like given below:


Runas :- /user:DomainAdminAccount@DOMAIN cmd

… that will punctual us for the credential of our DomainAdminAccount. If certified, we shall be handed the commands shell executing as Admin.



Verified the Installation of Program(This is the step for an optional information)


With this WMIC prompt, you can inquire several question of any nodes (or node) and get few goodly formatted responses. Though formatting the responses is on the far side of scope of such "How To", much more information’s can be got through the internet. 


So let us get out if the specific nodes even have our targets software (Spice-works does effort to list this info in its software scans)


> /node : COMPUTERNAME product find name,vendor, versions.

Such commands ask WMI to response with the list containing the Name,Vendor and Version of all complaints regarding the installations of software. 


If we would want to filter for a particular product, we may do so. Here is an illustration scanning a network machines for all configured applications from vendors "Apple, Inc"

> node:ANOTHEREXAMPLE products where vendors = "Apple Inc." receive the names,vendors


(*Note from Ander4221:
A little hint if we have particular character like '-' or '/' in the name of computers we require to utilize the ' ' character in order to receive the info from clients)

(**Note from Joe3034: 
 
Here is how we utilize the wild-cards in our searches:

Environment the like phrases in double quote and our searching criteria in single quote, and utilize the % as the wild-card symbols.


e.g.:
/node : ComputerXYZ products where "vendor like 'adobe%'" get name, version, identifyingNumber )



Uninstallation Calling


So I can create the call to the WMI surface to uninstall the specific products... let us choice on the MobileMe Control Panel from our former examples. The commands:


>/node : EXAMPLE products where name = "MobileMe Control Panel" call uninstall


... will prompt us for verification in the given below (long) formats:


Execute (\\EXAMPLE\ ROOT\CIMV2 : Win32_Product.IdentifyingNumber = "{6DA9102E-199F-43A0-A36B-6EF48081A658}", Name = "MobileMe Control Panel",Version="2.1.0.24")->Uninstall() (Y/N/?)? 
 

.. to which we must answer 'y' if we like to uninstall. WMI compliants software will execute the default uninstalation procedure without the users requiring to do anything (they get no prompt etc).

**Note that we can also use this 

- /nointeractive flag like - /node:EXAMPLE products where name ="MobileMe Control Panel" call uninstall /nointeractive to forestall the request of verification!
-thx Bart2691

Call Uninstall for a List of Machines (an optional informative step)


Let us expect we just received words that Adobe Reader has a earnest flaw in it is old versions. In a panic, we asked all our user to blindly set up the new versions of Adobe reader straights from website of Adobe. Gratefully, they all also succeeded to do so... however we have found 3 tickets so far about an Acrobat.com icons on available desktop. 


We have the flat text files of all our name of computer saved in c:\computer.txt. We pop up open a WMIC shell with proper permission and input the given below command :


/failfast:on /node:@"c:\computers.txt" products where name = "Acrobat.com" call uninstall /nointeractive


Which repeats via our list, skipping the nodes that are bad (eg:machines are turned off) and those that do not meet the criteria. We shall requirement to confirm 'y' that we like to uninstall on every nodes unless we utilize the non-interactive flags.


* Updated Notes from Bart2691 
 
... a simple mode to automate responsive 'Yes'. Example for acting it by PC or a text files are to utilize the /nointeractive flags. Additionally, if we do not like to hang on failed node, utilize the /failfast : on flag to speedily skip the nodes that is not answering.


** note from true911(unconfirmed)
The correct flags are failfast : on, not the fastfail : on

wmic /failfast:on /node:@"FILENAME.txt" products where "name like 'microsoft office professional edition 2003'" call uninstall /nointeractive

Uninstall Apps Remotely Through Command Line
Uninstall Apps Remotely Through Command Line

Conclusion


Hopefully we have been plotted by the effectiveness of WMIC. Though command line utilize of the uninstall call can't be commonly required with tools of software management, AD, etc... it can sometime be the best mode to execute the task speedily without interrupting our users.
Let us hope spice-works take its WMI execution the step further in a future automates and release such for us.)


No comments:

Post a Comment

Popular Posts