Jump to content
Sign in to follow this  

Getting script return code with StdOutRead

Recommended Posts

Hi all,

I am running the following command:

$val = Run(@ComSpec & " /c " & chr(34) & $CmdLineRaw & chr(34), @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

then reading the output with StdOutRead. All works fine, except for the fact that $val seems to contain a random return code from the command. The value of $CmdLineRaw is a VBS script that ends with the line WScript.Quit(2). But $val never gets the value of 2 (it looks like it contains the process ID of the command when it ran.

Before I added StdOutRead to Run command, $val was receiving the return code correctly.

Any ideas what I am doing wrong? I suspect that it is because I am using the "cmd /c" part, but using that was the only way I could get StdOutRead to work.



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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...