Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving the output from a command line

Applications

Retrieving the output from a command line

by  JPBERGEZ  Posted    (Edited  )
The following code uses the Windwos 2OOO RSK tool whoami to identify the current user ans his group membership, then retrieve the output from this command to display it. I know it's not wonderful but this is an example ;-)

Code:
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

'The tool is launched
Set oExec = WshShell.Exec("Whoami /all")

'We wait for the end of process
Do While oExec.Status = 0
     WScript.Sleep 100
Loop

'We scan and display the command output flow 
Do While oExec.StdOut.AtEndOfStream <> True 
          Wscript.Echo oExec.StdOut.ReadLine
Loop

Remarks:
* does'nt work with shell commands (dir, type etc...)
* The stdOut.ReadLine can be replaced with a StdOut.Read(1) to allow reading the stdOut character by character.
* The StdOut property does exist too. Not yet tested.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top