从Autoit执行powershell脚本?

时间:2017-01-13 21:54:26

标签: powershell autoit

如何从AutoIt代码执行powershell脚本?

我认为它可能类似于:

Runwait(@ComSpec & " /c powershell.exe c:\Mytest.ps1", "", @SW_HIDE)

Runwait(powershell.exe c:\Mytest.ps1", "", @SW_HIDE)

但这些似乎都没有起作用。

2 个答案:

答案 0 :(得分:2)

gunicorn -c app.conf -w3 --certfile=/etc/letsencrypt/live/mtfmu4.tk/cert.pem --keyfile=/etc/letsencrypt/live/mtfmu4.tk/privkey.pem api:app

并右键单击au3文件,然后选择“运行脚本(x64)'

测试我使用的powershell脚本:

Runwait("powershell.exe c:\Mytest.ps1", "", @SW_HIDE)

答案 1 :(得分:-1)

我结束了,这个解决方案似乎有效:

Local $iPID = Run('powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file C:\MyScript.ps1"', "c:\", @SW_HIDE, $STDOUT_CHILD)
; Wait until the process has closed using the PID returned by Run.
ProcessWaitClose($iPID)
; Read the Stdout stream of the PID returned by Run. 
Local $sOutput = StdoutRead($iPID)