使用命令行参数执行外部程序
Execute external program with command line arguments
我想使用 ShellExecuteWait()
从 AutoIt 执行 Python 脚本。我的尝试:
$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("E:/Automation/Python/Scripts/ReadLog.py", '-f "file.log" -k "key" -e "errMsg" ')
如何使用 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
的字符串)。
相关:How to run or execute python file from autoit.
检查 Python 二进制文件的路径(例如 Python.exe,无论 Python program/binary 位于何处)在 Window 的系统中 environment/path.
Execute Python script from AutoIt 如果路径存在,那么您的代码必须有效。在 $x
中,您将收到 Python 脚本的 return 退出代码。
你也可以试试:
RunWait('full_path\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg"', 'full_path_of_working_directory')
AutoIt 不会执行外部 programs/scripts 直到您传递工作目录(所有执行和 运行 命令的可选参数)。所以将工作目录作为一个单独的参数传递,它将起作用:
RunWait('full_path\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg"', 'full_path_of_working_directory')
我想使用 ShellExecuteWait()
从 AutoIt 执行 Python 脚本。我的尝试:
$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("E:/Automation/Python/Scripts/ReadLog.py", '-f "file.log" -k "key" -e "errMsg" ')
如何使用 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
的字符串)。
相关:How to run or execute python file from autoit.
检查 Python 二进制文件的路径(例如 Python.exe,无论 Python program/binary 位于何处)在 Window 的系统中 environment/path.
Execute Python script from AutoIt 如果路径存在,那么您的代码必须有效。在 $x
中,您将收到 Python 脚本的 return 退出代码。
你也可以试试:
RunWait('full_path\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg"', 'full_path_of_working_directory')
AutoIt 不会执行外部 programs/scripts 直到您传递工作目录(所有执行和 运行 命令的可选参数)。所以将工作目录作为一个单独的参数传递,它将起作用:
RunWait('full_path\Python.exe ReadLog.py -f "file.log" -k "key" -e "errMsg"', 'full_path_of_working_directory')