###Function###
Run

###Description###
Runs an external program.

###Syntax###
Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )


###Parameters###
@@ParamTable@@
program
	The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).
workingdir
	[optional] The working directory. Blank ("") uses the current working directory.  This is not the path to the program.
show_flag
	[optional] The "show" flag of the executed program:
		@SW_HIDE = Hidden window (or Default keyword)
		@SW_MINIMIZE = Minimized window
		@SW_MAXIMIZE = Maximized window
opt_flag
	[optional] Controls various options related to how the parent and child process interact.
		0x1 ($STDIN_CHILD)  = Provide a handle to the child's STDIN stream
		0x2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream
		0x4 ($STDERR_CHILD) = Provide a handle to the child's STDERR stream
		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.
@@End@@

###ReturnValue###
@@ReturnTable@@
Success:	the PID of the process that was launched.
Failure:	0 and sets the @error flag to non-zero.
@@End@@


###Remarks###
$RUN_* , $STIN_* , $STOUT_* , $STDERR_* constants require #include <AutoItConstants.au3>
Paths with spaces need to be enclosed in quotation marks.

To run DOS (console) commands, try <em><a href="Run.htm">Run</a>(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)	; don't forget " " before "/c"</em>

After running the requested program the script continues.  To pause execution of the script until the spawned program has finished use the <a href="RunWait.htm">RunWait()</a> function instead.

Providing the Standard I/O parameter with the proper values permits interaction with the child process through the <a href="StderrRead.htm">StderrRead()</a>, <a href="StdinWrite.htm">StdinWrite()</a> and <a href="StdoutRead.htm">StdoutRead()</a> functions. Combine the flag values (or use $STDERR_CHILD, $STDIN_CHILD & $STDOUT_CHILD) to manage more than one stream.

In order for the streams to close, the following conditions must be met: 1) The child process has closed its end of the stream (this happens when the child closes).  2) AutoIt must read any captured streams until there is no more data.  3) If STDIN is provided for the child, <a href="StdinWrite.htm">StdinWrite()</a> must be called to close the stream.  Once all streams are detected as no longer needed, all internal resources will automatically be freed.
<a href="StdioClose.htm">StdioClose()</a> can be used to force the STDIO streams closed.


###Related###
ConsoleRead, ProcessClose, RunAs, RunAsWait, RunWait, ShellExecute, ShellExecuteWait, StderrRead, StdinWrite, StdioClose, StdoutRead


###Example###
@@IncludeExample@@
