1

我正在使用以下代码来执行合并操作。此命令启动子进程(手动合并工具)。但无法打开使用此代码的子进程。但我得到错误和输出流

WshShell = new ActiveXObject("WScript.Shell");
var launch="tf merge $/Alpha/Dev $/Alpha/Main /recursive /version:C4264~C4264";
var cmdRun = WshShell.Exec(launch);

但是当我使用以下代码时,会启动子进程。但是一旦操作完成,窗口就会关闭。但我无法获得任何输出或错误流。

WshShell = new ActiveXObject("WScript.Shell");
var launch="tf merge $/Alpha/Dev $/Alpha/Main /recursive /version:C4264~C4264";
var cmdRun = WshShell.run(launch,1,1);

如何在仍然使用 Run() 方法的同时获得命令行查询的输出??????

4

1 回答 1

2
var WshShell = new ActiveXObject("WScript.Shell");
var WshExec = WshShell.Exec("nslookup");
var InStream = WshExec.StdIn;
InStream.writeLine("help");
InStream.writeLine("exit");
var OutStream = WshExec.StdOut;
var Str = "";
while (!OutStream.atEndOfStream) {
    Str = Str + OutStream.readAll();
}
WScript.Echo(Str);
于 2013-10-17T03:09:22.380 回答