WMIC in Windows

This is why I love computing, you learn something new all the time. WMIC (Windows Management Instrumentation Command-line tool) is something I have never even heard of until yesterday. It always seems when I am looking for a solution I find something in the blogosphere around the same time, but this is crazy. With this tool, you can query WMI info straight from the command line, this pretty much makes getting info on your machine 1000% times easier, especially from batch files, or programming interfaces. As an example, to go along with my “NumLock Debacle Fixer” in my previous posts, I used this

wmic SystemEnclosure get ChassisTypes

on the command line, and it throws me back a number. With a little research, I found what that means

10 = Laptop
12 = Docked
5 = Pizza Box (wtf??)

Anyways, I tested it and yeah, it gives me the correct info, so in my program, I shell out, get the output back, parse it out, and I have what I need, but the cool thing is, you can query any WMI info from the command line, which opens up a ton of options, especially for sysadmins and network guys. Along with utils in XP like reg.exe, you pretty much can write some powerful scripts/programs without using anything but windows utils. Of course there are API’s for programmers to do these things in code, but sometimes its more headache then it is worth, especially when you want to just write a quick batch file to do something.

What other tools or tricks have you found in xp? (shutdown -i, tasklist /s, etc)

Advertisements

One thought on “WMIC in Windows”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s