Jump to content
Sign in to follow this  
dragonlord

capture RunAsWait output

Recommended Posts

dragonlord

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 machine

  • The opt_flag parameter seems to have only a 0x10000 ($RUN_CREATE_NEW_CONSOLE) option, unlike the RunAs function
Pointers are appreciated.

Thx.

Share this post


Link to post
Share on other sites
Skruge

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]

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  

×