windows – JScript:如何运行外部命令并获得输出?
发布时间:2020-09-01 17:26:20 所属栏目: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中,它是对函数的调用,必须包括括号 (编辑:哈尔滨站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows10下安装source insight 4.0
- 有没有办法在Windows cli中使用’COPY’命令(PostgreSQL)?
- windows-installer – installshield和windowsinstaller之间
- windows-10 – Windows 10移动设备错误:DEP6200
- windows-7 – 在windows7中设置JRE路径的要求,如设置JDK的路
- Windows – 如何将多个文件名传递给上下文菜单Shell命令?
- Windows C线程参数传递
- windows-phone-7 – 如何将SystemTray Progressbar绑定到选
- windows – PSExec如何以SYSTEM用户身份运行应用程序?
- windows下编译支持https的libcurl
推荐文章
站长推荐
热点阅读