Here's what I'm trying to do:
MyProgram.exe | cscript myvbscript.vbs /message:"reporting errorlevel %errorlevel%"
The problem with this is that the expanded %errorlevel% value is the one from before MyProgram.Exe runs, not after. When I tried /message:"errorlevel $errorlevel$" and in the script replacing $'s with %'s and running that through Shell.ExpandEnvironmentStrings it didn't work. The string "%errorlevel%" isn't expanded, probably because it's not a "real" environment string but replaced specially by the command interpreter.
I thought I could do something like Shell.Exec("echo %errorlevel%") and then read out the error level with StdOut.ReadLine on the exec object that returns, but Exec is looking for an executable file name and doesn't accept instructions for the command interpreter. ("The system cannot find the file specified.")
I know that I can Exec a process from inside the vbscript and get the errorlevel back from it:
cscript myvbscript.vbs /commandline:"MyProgram.exe" /message:"reporting errorlevel %errorlevel%"
but that's not how I would like to use this .vbs script.
Searching for vbscript and errorlevel yields 17,000 hits, mostly talking about setting errorlevel on exit or other random things with batch files & errorlevels, but not what I am looking for. Any ideas?
[COLOR=#aa88aa black]Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.[/color]
MyProgram.exe | cscript myvbscript.vbs /message:"reporting errorlevel %errorlevel%"
The problem with this is that the expanded %errorlevel% value is the one from before MyProgram.Exe runs, not after. When I tried /message:"errorlevel $errorlevel$" and in the script replacing $'s with %'s and running that through Shell.ExpandEnvironmentStrings it didn't work. The string "%errorlevel%" isn't expanded, probably because it's not a "real" environment string but replaced specially by the command interpreter.
I thought I could do something like Shell.Exec("echo %errorlevel%") and then read out the error level with StdOut.ReadLine on the exec object that returns, but Exec is looking for an executable file name and doesn't accept instructions for the command interpreter. ("The system cannot find the file specified.")
I know that I can Exec a process from inside the vbscript and get the errorlevel back from it:
cscript myvbscript.vbs /commandline:"MyProgram.exe" /message:"reporting errorlevel %errorlevel%"
but that's not how I would like to use this .vbs script.
Searching for vbscript and errorlevel yields 17,000 hits, mostly talking about setting errorlevel on exit or other random things with batch files & errorlevels, but not what I am looking for. Any ideas?
[COLOR=#aa88aa black]Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.[/color]