The GUI INF script language provides two commands that enable you to execute another program from an INF script. From a shell or install section, you can use the RunProgram and StartDetachedProcess commands to start another program, and you can use the WaitOnEvent and SignalEvent commands to synchronize execution between the INF script and a program started by StartDetachedProcess.
The RunProgram command executes the specified program and stores the program’s exit code under the ExitCode variable. To the INF script, it appears that the program is executed synchronously, because execution of the INF script waits for the program to terminate. Internally, however, the Setup program executes the program asynchronously and then uses a loop to wait for the program’s termination while yielding periodically to handle messages. This enables the Setup program to be responsive to user interactions during the wait. The syntax of this command is:
RunProgram ExitCode DiskName Reserved ProgramPath [Args]*
For example:
RunProgram ExitCode "Setup Disk #1" "" a:\setupprg.exe
The StartDetachedProcess command executes the specified program asynchronously, using the CreateProcess function of the Win32 API (with the DETACHED_PROCESS flag). Execution of the INF script continues without waiting for the process to terminate. The syntax of the command is:
StartDetachedProcess ExitCode DiskName Reserved ProgramPath [Args]*
For example:
StartDetachedProcess Success "Setup Disk #1" "" a:\setupprg.exe
The WaitOnEvent command opens a handle to the specified event object. It then waits for either the object’s state to be signaled or the timeout interval to elapse. This command blocks the execution of the INF script, but, internally, the Setup program uses a loop to wait for the event to be signaled while yielding periodically to handle messages. This enables the Setup program to be responsive to user interactions during the wait.
This command is useful in coordinating execution of the INF script with an external program started by the StartDetachedProcess command. If the first character of the EventName string is an asterisk (*), a variation of the WaitOnEvent operation is performed. In this case, the detached process can signal either the named event or an event named \\SETUP_FAILED. It signals the EventName event to indicate success, and signals the \\SETUP_FAILED event to indicate that the process failed and an error popup has already been presented to the user.
Note that the Setup program does not create the EventName event if it does not exist. This means that you must allow time for the detached process to create the event. The syntax of the command is:
WaitOnEvent Result EventName Timeout
“EventSet” - The EventName event was signaled.
“EventNotFound” - No event object exists with the specified name.
“EventTimeout” - The timeout interval elapsed before the event was signaled.
“EventFailed” - The \\SETUP_FAILED event was signaled.
The SignalEvent command opens a handle to the specified event object, and sets its state to signaled. The Setup program does not create the EventName event if it does not exist. The syntax of the command is:
SignalEvent Result EventName
“EventSignaled” - The event’s state was set to signaled.
“EventNotSet” - The event’s state could not be set to signaled.
“EventNotFound” - No event object exists with the specified name.