windows – JScript:如何运行外部命令并获得输出?
发布时间:2020-09-01 16:21:35 所属栏目: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中,它是对函数的调用,必须包括括号 (编辑:台州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何正确创建一个nim / nimrod windows dll
- windows – dokan sshfs有多稳定?
- windows-phone-7 – 如何将SystemTray Progressbar绑定到选
- 在Windows上使用clang编译c 11程序时出错
- Windows下wamp php单元测试工具PHPUnit安装及生成日志文件配
- windows-phone-8 – 新的Live磁贴在Windows Phone Silverli
- Windows Azure表存储行大小限制小于规定的1MB
- php在windows环境下获得cpu内存实时使用率(推荐)
- 在没有Microsoft.NET.Sdk.Web的情况下使用Razor
- https – 如何在非Windows平台上忽略“System.Net.Http.Cur
推荐文章
站长推荐
- windows-8 – 在MetroStyle应用程序中使用COM对象
- windows-phone-8.1 – 如何检测在Windows 10 Mob
- .net – System.Windows.Forms.WebBrowser:强制
- 获取与Windows Vista上的C#.Net连接的无线网络的
- .net – 如何通过webclient下载图像(jpg)并保存到
- 找出占用Installer 目录空间的元凶
- WPF:xaml中的权力
- wpf – xaml Scrollviewer – 禁用整个窗口的过度
- Windows Server 2016-安装AD域服务注意事项
- Windows:忘记本地账户开机密码,但记得住PIN码
热点阅读