命令行 – 如何在使用vbscript Exec时显示DOS输出
发布时间:2020-12-14 01:55:02 所属栏目:Windows 来源:网络整理
导读:我有以下VBScript: Set Shell = WScript.CreateObject("WScript.Shell")commandLine = puttyPath "plink.exe -v" " -ssh" [plus additional commands here] Set oExec = Shell.Exec(commandLine) 这会导致出现DOS窗口,但不会显示plink.exe的输出.有没有办
我有以下VBScript:
Set Shell = WScript.CreateObject("WScript.Shell") commandLine = puttyPath & "plink.exe -v" & " -ssh" [plus additional commands here] Set oExec = Shell.Exec(commandLine) 这会导致出现DOS窗口,但不会显示plink.exe的输出.有没有办法让DOS窗口显示此输出? 解决方法
Windows脚本主机缺少一个system()命令所以你必须实现自己的,恕我直言我的助手功能优于stealthyninja的版本,因为它等待进程退出而不只是空stdout,它还处理stderr:
Function ExecuteWithTerminalOutput(cmd) Set sh = WScript.CreateObject("WScript.Shell") Set exec = sh.Exec(cmd) Do While exec.Status = 0 WScript.Sleep 100 WScript.StdOut.Write(exec.StdOut.ReadAll()) WScript.StdErr.Write(exec.StdErr.ReadAll()) Loop ExecuteWithTerminalOutput = exec.Status End Function call ExecuteWithTerminalOutput("cmd.exe /c dir %windir%*") (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Windows 2008 R2 DHCP – 客户端更新过于频繁
- Windows Azure存储模拟器 – CORS支持
- 微信图片解决方法-windows版的dat文件
- 如何检测Windows XP机器上是否播放任何声音
- 如何在Windows 64位上安装numpy mkl for python
- windows – 如何使用远程桌面发送ctrl alt del?
- Windows Server如何与Windows桌面进行不同的优化
- TypeScript编译器在Windows上使用什么JavaScript
- 使用QEMU创建Windows 2008虚拟化映像时出现问题
- windows-server-2003 – 配置文件和主路径之间的
热点阅读