Howdy. I cannot find any documentation on this, so I assume it is likely impossible. If one wanted to query info from one WMI class (like, say, if a user is logged) in WMIC and then call a method from another (like rebooting if a user is not logged), can one even do this?

Yes, I know: this is best handled as a script. I am looking for a quick one-liner for when I need to patch things in a lab quickly. I want combine these two in particular:

 If (wmic computersystem where username=null call) -> wmic os call reboot

So, it would look in my mind:

 wmic computersystem where username=null call (syntax here to call reboot method from os alias)

Now, just so we are all on the same page, I am aware there are some cheapish hacks to do this, like linking commands with && and findstr looking for the No instances available message, but I am very curious if one can combine classes this way. WMIC has become the only thing MSFT developed that I like, and I would love to find out it that much more powerful for me.

link|improve this question

59% accept rate
don't think its possible! – tony roth Jul 19 '10 at 16:45
you'll need to move to the next msft thing that you'll like, powershell! – tony roth Jul 19 '10 at 16:58
@tony roth I was afraid of this. I wanted a quick one-liner I could copy and paste for emergencies with psexec to avoid sloppy scripting and tout my brevity. Oh well. – alharaka Jul 21 '10 at 13:25
@alharaka it can be a powershell one liner that should be good enough right! With me if it takes more then one line of code then something must be wrong! – tony roth Jul 21 '10 at 14:28
@tony roth Not to start a flame war or anything, but what PowerShell, or what I like to call it, PoS, makes up for in the terseness it passes off to wasted system utilization. I have a 7 VM running and I wanted to filter a log with sensitive PINs in it before giving to a vendor. I wrote a terrible one-liner in PS to do it, and consumed damn near half of my memory (512/1024) and the VM grinded to halt. Switch to a Debian VM, used sed, and it took a fraction of time and resources. Also, I have to keep up with some XP machines, which as you know can and cannot allow for remote PS, it depends. – alharaka Jul 21 '10 at 15:38
show 1 more comment
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.