我试图从HTML应用程序[HTA]调用powershell脚本:
Set WshShell = CreateObject("WScript.Shell")
Set retVal = WshShell.Exec("powershell.exe C:\PS_Scripts\test.ps1")
Run Code Online (Sandbox Code Playgroud)
test.ps1只返回进程计数
return (Get-Process).Count
Run Code Online (Sandbox Code Playgroud)
我想获取此powershell脚本的输出,然后将其存储在本地变量中或显示在HTA上.如何才能做到这一点 ?
我试过用:
retVal.StdIn.Close()
result = retVal.StdOut.ReadAll()
alert(result)
Run Code Online (Sandbox Code Playgroud)
但打印结果值为null.
请帮我解决这个问题.