in reply to Execute wmic command in cmd

If you only want one piece of information, do it all as a single command:

@output = `wmic diskdrive get status`;; print "@output";; Status OK

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Execute wmic command in cmd
by mvip (Acolyte) on May 15, 2013 at 17:39 UTC

    Tnx for the reply. I dont think we understand....maybe i confuse u with that telling you "is like telent". So i will try explain again. The first command when i execute is like this:

    C:\Users\mypc\Desktop\Perl>wmic wmic:root\cli>

    so as you can see wmic command is execute and i got the "wmic:root\cli>" prompt and here i have to execute the "diskdrive get status" command that will show me if the disk is ok or not. Here is how it looks like all the procedure ....

    C:\Users\mypc\Desktop\Perl>wmic wmic:root\cli>diskdrive get status Status OK wmic:root\cli>
      as you can see wmic command is execute and i got the "wmic:root\cli>" prompt and here i have to execute the "diskdrive get status" command that will show me if the disk is ok or not.

      You can do it that way. (Ie. interactive mode.)

      But, you can also do it all in one go: wmic diskdrive get status as I showed above. (Try it it on your command line. )

      And the second way is the easiest way to do it from a program. (Again; try the code I posted for yourself.)

      It is not just the easiest way. Trying to use the interactive mode from within a Perl program is (almost) impossible.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      mvib:

      As you can see below, you can either use wmic interactively ("like telnet") or as a simple command-line driven program.

      H:\>wmic wmic:root\cli>diskdrive get status Status OK wmic:root\cli>quit H:\>wmic diskdrive get status Status OK H:\>

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Well tnx guys i just dont see the other comma `` i was using the others '' i forgot about writhing in Perl :S sorry any way tnx and it works

        now im trying to put the results in a variable ...