Reading Pipe from cmd.exe that uses "start" builtin -
i'm attempting "leave message" current user (on windows) using wscript.exe, without waiting user acknowledge message.
my thought create new process, using "start" builtin (it opens new window , execution control returns caller) , call wscript short script open message box on screen , exit.
this works ok unless attempt open pipe script (and read it). if attempt read pipe, read i/o never gets eof until wscript.exe exits, though program continues execution after "start" command.
here's example:
test.vbs
wscript.echo "hello world!"
invoke.cmd
start wscript.exe //nologo test.vbs @echo exiting... exit /b
if run invoke.cmd in command prompt, wscript window opens , control returns prompt.
however, if attempt pipe output command (that attempts read pipe), subcommand never seems see pipe has closed until wscript.exe exits.
this behavior doesn't require wscript.exe, however. seems behave way long process created "start" still running. can same behavior "cmd.exe /k".
invoke2.cmd
start cmd /k date /t @echo exiting... exit /b
attempting read pipe invoke2.cmd blocks until "start"-ed process ends.
i don't see command-line args "start" claim govern behavior this, , don't understand why cmd.exe that's using "start" create new processes/windows won't exit until "start"-ed window exits.
curiously enough, things work if redirect output file. doesn't work pipe.
any ideas?
since using wscript.exe, popping message box on echo command. try running
start cscript.exe //nologo test.vbs
cscript.exe command line version, output command line.
Comments
Post a Comment