JScript: how to run external command and get output?
问题 I'm running my JScript file using cscript.exe. In the script I need to call an external console command and get the output. Tried: var oShell = WScript.CreateObject("WScript.Shell"); var oExec = oShell.Exec('cmd /c dir'); WScript.Echo("Status "+oExec.Status); WScript.Echo("ProcessID "+oExec.ProcessID); WScript.Echo("ExitCode "+oExec.ExitCode); and var oShell = WScript.CreateObject("WScript.Shell"); var ret = oShell.Run('cmd /c dir', 1 /* SW_SHOWNORMAL */, true /* bWaitOnReturn */); WScript