首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Autoit执行powershell脚本?

从Autoit执行powershell脚本?
EN

Stack Overflow用户
提问于 2017-01-13 21:54:26
回答 2查看 9.7K关注 0票数 0

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

我想可能是这样的:

代码语言:javascript
复制
Runwait(@ComSpec & " /c powershell.exe c:\Mytest.ps1", "", @SW_HIDE)

代码语言:javascript
复制
Runwait(powershell.exe c:\Mytest.ps1", "", @SW_HIDE)

但这两种方法似乎都没有用。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-14 02:56:37

代码语言:javascript
复制
Runwait("powershell.exe c:\Mytest.ps1", "", @SW_HIDE)

右键单击au3文件并选择“运行脚本(X64)”

测试我使用的powershell脚本:

代码语言:javascript
复制
"heelllo" >> h:\somesome.txt
票数 3
EN

Stack Overflow用户

发布于 2017-01-20 16:16:14

最后,这个解决方案似乎奏效了:

代码语言:javascript
复制
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)
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41644031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档