dragonlord Posted May 7, 2013 Share Posted May 7, 2013 How can i capture the output of Runaswait?Local $foo = RunAsWait($sUserName, $domain, $sPassword, 1, "C:\band7Deploy\PsExec.exe \\10.80.100.134 -s -h -u CORP2\username -p password -c -v GhostTaskStatus.cmd", "C:\band7Deploy",@SW_MAXIMIZE)I tried redirecting the output to a file (which is ok coz i can parse the file and get what i want)Local $foo = RunAsWait($sUserName, $domain, $sPassword, 1, "C:\band7Deploy\PsExec.exe \\10.80.100.134 -s -h -u CORP2\username -p password -c -v GhostTaskStatus.cmd >info.txt", "C:\band7Deploy",@SW_MAXIMIZE) .But the redirection is getting picked-up as part of the psexec command and not producing info.txt on my local machineThe opt_flag parameter seems to have only a 0x10000 ($RUN_CREATE_NEW_CONSOLE) option, unlike the RunAs functionPointers are appreciated.Thx. Link to comment Share on other sites More sharing options...
Skruge Posted May 7, 2013 Share Posted May 7, 2013 1. Redirection is handled by cmd.exe, which is being bypassed, so a quick change would be to add it in: Local $foo = RunAsWait($sUserName, $domain, $sPassword, 1, @comspec & " /c C:\band7Deploy\PsExec.exe \\10.80.100.134 -s -h -u CORP2\username -p password -c -v GhostTaskStatus.cmd >info.txt", "C:\band7Deploy",@SW_MAXIMIZE) 2. You can use RunAs instead of RunAsWait to take advantage of stream handling without using cmd.exe. The helpfile examples for StdoutRead/StderrRead wait for the process to complete, which sounds like your original intention. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now