windows – JScript:如何运行外部命令并获得输出?
发布时间:2020-09-01 17:27:49 所属栏目: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 – dokan sshfs有多稳定?
- windows-phone-8 – 新的Live磁贴在Windows Phone Silverli
- 类共享警告不允许我使用visualVM在本地(Windows)进行配置
- windows-7 – 无法完成操作,因为文件夹或其中的文件在另一个
- winapi – Win32 No-MFC中的消息映射
- 身份验证错误 要求的函数不受支持 Windows远程桌面连接
- haskell – 用于Windows的Linux主机上的GHC交叉编译源代码
- wcf – 有关替换Microsoft .NET的Web服务增强功能(WSE)3.0的
- 在WPF中的所有Windows中应用按钮样式
- Windows Phone 7 – Windows Phone开发Visual Studio 2012
