windows – JScript:如何运行外部命令并获得输出?
发布时间:2020-09-01 17:28: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中,它是对函数的调用,必须包括括号 (编辑:百色站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-phone-8.1 – 升级到最新Windows Phone 8.1后无法发
- Windows下动态加载的库的地址范围
- tfs – 在测试用例通过或失败时发送电子邮件警报
- windows – PSExec如何以SYSTEM用户身份运行应用程序?
- windows-phone-8 – 添加辅助Windows Phone 8磁贴
- 获取与Windows Vista上的C#.Net连接的无线网络的SSID
- windows-phone-7 – 如何将SystemTray Progressbar绑定到选
- windows – 为什么没有64位版本的VS2013?
- windows – JScript:如何运行外部命令并获得输出?
- 在没有Microsoft.NET.Sdk.Web的情况下使用Razor
推荐文章
站长推荐
- 在Windows上使用clang编译c 11程序时出错
- Windows 8应用程序是否运行符合标准的JavaScript
- tfs – 在测试用例通过或失败时发送电子邮件警报
- Microsoft Dynamics(Navision)vs C#.NET
- windows-ce – Windows CE的应用程序开发
- windows-server-2008 – Windows Server 2008 R2
- windows – procdump -t – 如何在进程终止时转储
- 如何在Windows上确定是否安装了C/C++编译器
- Windows – 如何将多个文件名传递给上下文菜单Sh
- windows-runtime – 将Action绑定到XAML中UserCo
热点阅读