Jump to content

Dos output to variable


botanic
 Share

Recommended Posts

I need to get the output of a command that runs in a command prompt, the problem is that run only returns a 1 or 0. I tried

#RequireAdmin $Command="cmd /c dir c: /s";<-Your command 
RunWait($command & ">" & @scriptdir & "\output.txt","") 
$OutPut = FileRead( @scriptdir & "\output.txt",FileGetSize(@scriptdir & "\output.txt")) 
MsgBox(0, "", $OutPut)  
FileDelete( @scriptdir & "\output.txt")

however the output.txt is blank even tho there is output.

Edited by botanic
Link to comment
Share on other sites

Using StdoutRead is a lot easier than using a temp file.

#include <Constants.au3>
#RequireAdmin 
$Command=@comspec & " /c dir c:\ /s";<-Your command 
$pid=Run($command,@SystemDir,@SW_HIDE,$STDERR_MERGED)
ProcessWaitClose($pid)
$output=StdoutRead($pid)
MsgBox(1,"output",$output)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...