Jump to content
Sign in to follow this  

DOS output to variable

Recommended Posts


I did some searching and it appears the way to do this is send the output to a temp text file and then read it back. Is there a simpler way?

RunWait( "cmd /c c:\windows\system32\snmputil.exe get Public ." & ">" & "temp.txt" )
$output= FileRead( "temp.txt", FileGetSize("temp.txt") )
FileDelete( "temp.txt" )

This works, just looking for input on the best way to run a DOS app and dump the output to a variable. Is the step of writing to a file needed?

Edited by SystemWontAccept

Share this post

Link to post
Share on other sites


Script writed by MAT.

It works excelent.

Local $sCommand = "c:\windows\system32\snmputil.exe get Public ." 

MsgBox (0, "", _RunCmd ($sCommand)) 

Func _RunCmd ($sCommand) 
 If StringLeft ($sCommand, 1) = " " Then $sCommand = " " & $sCommand 

 Local $nPid = Run (@Comspec & " /c" & $sCommand, "", @SW_Hide, 8), $sRet = "" 
 If @Error then Return "ERROR:" & @ERROR 
 ProcessWait ($nPid) 
 While 1 
 $sRet &= StdoutRead($nPID) 
 If @error Or (Not ProcessExists ($nPid)) Then ExitLoop 
 Return $sRet 
EndFunc ; ==> _RunCmd

[size="5"] [/size]

Share this post

Link to post
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
Sign in to follow this