| WMIC (Windows Management Instrumentation | | | | Surround the like phrase in double quotes and your |
| Command-Line) is a potent tool that often doesn't | | | | search criteria in single quotes, and use % as the |
| see much use due to the lack of (easily accessible) | | | | wildcard symbol.e.g.: /node:ComputerXYZ product |
| documentation available. For this technical article for | | | | where "vendor like 'adobe%'" get |
| IT professionals, we'll be using WMIC with domain | | | | name,version,identifyingNumber ) |
| admin credentials to crawl through a list of nodes | | | | 4. Call for the Uninstallation |
| (PCs/Laptops) and uninstall an example program | | | | So we can make a call to the WMI interface to |
| without interrupting the user. | | | | uninstall a particular product... let's pick on the |
| 1. Load up a command shell with appropriate access | | | | MobileMe Control Panel from our previous example. |
| permissions | | | | The command: |
| Though a WMIC instruction can be given appropriate | | | | >/node:EXAMPLE product where name="MobileMe |
| credentials prior to operation, it is typically | | | | Control Panel" call uninstall |
| best-practice to avoid clear-text typing the password | | | | ... will prompt you for confirmation in the following |
| (who is that looking over your shoulder;)). We'll | | | | (long) format: |
| execute the runas command like the following: | | | | Execute |
| Runas /user:DomainAdminAccount@DOMAIN cmd | | | | me="MobileMe Control |
| ... which will prompt us for the credentials of our | | | | Panel",Version="2.1.0.24")->Uninstall() (Y/N/?)? |
| DomainAdminAccount. If authenticated, we'll be | | | | .. to which you must reply 'y' if you wish to uninstall. |
| handed a command shell running as the Admin. | | | | WMI compliant software will run the default |
| 2. Step into WMIC | | | | uninstallation procedures without the user needing to |
| One of the nice features of WMIC is that it may be | | | | do anything (they receive no prompts etc). |
| run from any machine. With our admin command shell, | | | | 5. Call Uninstall for a List of Machines (an optional |
| we're going to enter the WMIC command followed | | | | informative step) |
| by enter. (Note: We could have jumped into WMIC | | | | Let's assume you just got word that Adobe Reader |
| directly from the runas command... this just breaks | | | | has a serious flaw in it's old version. In a panic, you |
| out the steps) | | | | asked all your users to blindly install the new version |
| 3. Verify Program Installation (an optional informative | | | | of Adobe reader straight from Adobe's site. |
| step) | | | | Thankfully, they all managed to do so... however |
| With our WMIC prompt, we can ask many questions | | | | you've received 3 tickets so far about an icon on the |
| of a node (or nodes) and receive some nicely | | | | desktop. |
| formatted replies. Though formatting the replies is | | | | You have a flat text file of all your computer's |
| beyond the scope of this "How To", much more | | | | names stored in c:computers.txt. You pop open a |
| information can be found on the Internet. | | | | WMIC shell with appropriate permissions and enter |
| So let's find out if a particular node even has our | | | | the following command: |
| target software: | | | | >/node:@"c:computers.txt" product where |
| >/node:COMPUTERNAME product get | | | | name="Acrobat.com" call uninstall |
| name,version,vendor | | | | Which iterates through your list, skipping nodes that |
| This command asks WMI to reply with a list including | | | | are invalid (eg:machine is turned off) and those that |
| the Name, Version, and Vendor of all compliant | | | | don't meet the criteria. You'll need to confirm 'y' that |
| software installations. | | | | you want to uninstall on every node... but that may |
| If you would like to filter for a specific product, you | | | | be a small price to pay for not needing to run around |
| may do so. Here's an example scanning a networked | | | | to every machine. |
| machine for all installed applications from the vendor | | | | Conclusion |
| "Apple, Inc" | | | | Hopefully you've been intrigued by the potency of |
| >/node:ANOTHEREXAMPLE product where | | | | WMIC. Though the command-line use of the uninstall |
| vendor="Apple Inc." get name,vendor | | | | call may not be commonly needed with software |
| A small hint if you have special characters like '-' or '/' | | | | management tools, AD, etc... it can sometimes be the |
| in the computer name you need to use ' ' characters | | | | best way to accomplish a task quickly without |
| in order to get information from client) | | | | disturbing your user(s). |
| Here is how you use wildcards in your search: | | | | Learn more about WMIC at their official web site. |