Capturing output from WshShell.Exec using Windows Script Host

后端 未结 5 574
无人及你
无人及你 2020-12-06 11:15

I wrote the following two functions, and call the second (\"callAndWait\") from JavaScript running inside Windows Script Host. My overall intent is to call one command line

5条回答
  •  隐瞒了意图╮
    2020-12-06 12:07

    You might have hit the deadlock issue described on this Microsoft Support site.

    One suggestion is to always read both from stdout and stderr. You could change readAllFromAny to:

    function readAllFromAny(oExec)
    {
      var output = "";
    
      if (!oExec.StdOut.AtEndOfStream)
        output = output + oExec.StdOut.ReadLine();
    
      if (!oExec.StdErr.AtEndOfStream)
        output = output + "STDERR: " + oExec.StdErr.ReadLine();
    
      return output ? output : -1;
    }
    

提交回复
热议问题