运行外部程序.
Run ( "程序" [, "工作目录" [, 显示标志[, 可选标志]]] )
程序 | 程序所在的完整路径(文件格式为 EXE,BAT,COM 或 PIF). |
工作目录 | [可选参数] 工作目录.这个路径不一定指向程序所在路径. |
显示标志 | [可选参数] 启动程序时的初始状态: @SW_HIDE = 隐藏窗口 @SW_MINIMIZE = 最小化窗口 @SW_MAXIMIZE = 最大化窗口 |
可选标志 | [可选参数] 控制不同选项处理父进程与子进程交互. 0x1 ($STDIN_CHILD) = 提供一个句柄到子进程的 STDIN 流. 0x2 ($STDOUT_CHILD) = 提供一个句柄到子进程的 STDOUT 流. 0x4 ($STDERR_CHILD) = 提供一个句柄到子进程的 STDERR 流. 0x8 ($STDERR_MERGED) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD. 0x10 ($STDIO_INHERIT_PARENT) = Provide the child with the parent's STDIO streams. This flag can not be combined with any other STDIO flag. This flag is only useful when the parent is compiled as a Console application. 0x10000 ($RUN_CREATE_NEW_CONSOLE) = The child console process should be created with it's own window instead of using the parent's window. This flag is only useful when the parent is compiled as a Console application. |
成功: | 返回所运行程序的 PID(进程标识符). |
失败: | 返回 0并设置 @error 为非0值. |
Example()
Func Example()
; Run Notepad with the window maximized.
Local $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED)
; Wait 10 seconds for the Notepad window to appear.
WinWait("[CLASS:Notepad]", "", 10)
; Wait for 2 seconds.
Sleep(2000)
; Close the Notepad process using the PID returned by Run.
ProcessClose($iPID)
EndFunc ;==>Example