【发布时间】:2018-10-27 00:33:33
【问题描述】:
我正在尝试将 HTML 应用程序 [HTA] 中的 powershell 脚本调用为:
Set WshShell = CreateObject("WScript.Shell")
Set retVal = WshShell.Exec("powershell.exe C:\PS_Scripts\test.ps1")
test.ps1 只是返回进程计数的地方
return (Get-Process).Count
我想获取这个 powershell 脚本的输出,然后将其存储在局部变量中或显示在 HTA 上。这是怎么做到的?
我尝试使用:
retVal.StdIn.Close()
result = retVal.StdOut.ReadAll()
alert(result)
但是打印出来的结果值为null。
请帮助我如何实现这一目标。
【问题讨论】:
-
您可以在代码中添加一些格式以使其更易于阅读吗?
-
@Marc 我也尝试了上述解决方案,将输出写入文件。但是文件内容又是空的。 powershell 在 powershell 控制台上正确打印输出(进程数)。 HTML 应用程序无法检索此信息。
标签: powershell hta