windows – JScript:如何运行外部命令并获得输出?
发布时间:2020-09-01 17:28:21 所属栏目:Windows 来源:互联网
导读:我正在使用cscript.exe运行我的JScript文件. 在脚本中,我需要调用外部控制台命令并获取输出. 尝试: var oShell = WScript.CreateObject(WScript.Shell);var oExec = oShell.Exec(cmd /c dir);WScript.Echo(Status +oExec.Status);WScript.Echo
我正在使用cscript.exe运行我的JScript文件.
尝试: 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); 和 var oShell = WScript.CreateObject("WScript.Shell"); var ret = oShell.Run('cmd /c dir',1 /* SW_SHOWNORMAL */,true /* bWaitOnReturn */); WScript.Echo("ret " + ret); 但没有运气:该命令运行(最有可能)没有错误,但我没有输出. 那么,我该怎么做呢? 更新: var oShell = WScript.CreateObject("WScript.Shell"); var oExec = oShell.Exec('cmd /c dir'); var strOutput = oExec.StdOut.ReadAll; WScript.Echo("StdOut "+strOutput); var strOutput = oExec.StdErr.ReadAll; WScript.Echo("StdErr "+strOutput); 错误是Microsoft JScript运行时错误:对象不支持此属性或方法var strOutput = oExec.StdOut.ReadAll;线 var strOutput = oExec.StdOut.ReadAll(); 在Javascript中,它是对函数的调用,必须包括括号 (编辑:甘南站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- winapi – Windows SDK 7.0的signtool中的signwizard发生了
- Windows – 无法从GitBash运行TASKKILL
- Windows 下安装 Node.js
- 在windows平台下采用electron-packager打包electron程序为.
- windows-phone-7 – 如何将SystemTray Progressbar绑定到选
- Windows – 如何将多个文件名传递给上下文菜单Shell命令?
- 如何在Windows Phone 7系列上获取屏幕尺寸?
- 什么是“Microsoft C例外”?
- Windows Server 2016-Win Ser 2016已删减内容
- Microsoft Unit Testing Framework for C++