我想用^{
$x = ShellExecuteWait("E:/Automation/Python/Scripts/ReadLog.py", '-f "file.log" -k "key" -e "errMsg" ')
MsgBox(0,"x=",String($x))
If @error Then
MsgBox(0,"Error=",String(@error))
EndIf
我可以在$x
中看到一些进程id,@error
也被设置为0
(意味着AutoIt执行了脚本)。但是我的Python脚本没有产生结果(它在独立执行时会写入一个txt文件)。似乎问题在于传递命令行参数,例如:
如何使用ShellExecuteWait()
传递命令行参数?语法:
ShellExecuteWait ( "filename" [, "parameters" [, "workingdir" [,"verb" [, showflag]]]] )
Parameters:
filename :- The name of the file to run (EXE, .txt, .lnk, etc).
parameters :- [optional] Any parameters for the program. Blank ("") uses none.
这会遗漏参数使用的范例。Python脚本没有问题(它需要3个命令行参数、带有选项-f
、-k
和-e
的字符串)。在
AutoIt在传递工作目录(所有execute和run命令的可选参数)之前不会执行外部程序/脚本。因此,将工作目录作为单独的参数传递,它将起作用:
检查Python二进制文件的路径(例如。Python.exe,在窗口的系统环境/路径中。在
Execute Python script from AutoIt如果存在路径,则代码必须正常工作。在
$x
中,您将收到Python脚本的返回退出代码。在您也可以尝试:
相关问题 更多 >
编程相关推荐