RUN statement
Purpose: Asynchronously start and run another program or system file
Syntax: RUN Name$ [, ShowWindowState, WaitState] Parameters:
|
Examples :
RUN "notepad.exe", SW_SHOW ' Start up Notepad RUN "start http://www.w3.org", SW_HIDE ' Launches default browser
In the example above, SW_HIDE is used to hide the DOS box that 'start' initiates. If you are using 'start' to execute a console application in a Windows DOS box and you want to see the screen output then set the parameter to one of the SW_SHOW parameters.
Remarks: The above example using 'start' will not work on Windows 2000 or XP because 'start' does not function in the same way on Windows 2000, XP as it does on Windows 95 and 98. There are two alternatives for 2000, XP users
1. Use Windows API:
ShellExecute(0, _ ' handle to parent window "open", _ ' pointer to string that specifies operation to perform "http://www.w3.org", _ ' pointer to filename string "", _ ' pointer to string that specifies executable-file parameters 0, _ ' pointer to string that specifies default folder 1 _ ' whether file is shown when opened )
Remarks: To use the ShellExecute WinAPI call you must link with SHELL32.LIB.
2. Use a macro :CONST RunEx(lpFile, _ lpParameters, _ nShowCmd) = _ ShellExecute(0, _ "open", _ lpFile, _ lpParameters, _ 0, _ nShowCmd)
Remarks: To use this macro you must link with SHELL32.LIB. The following shows how RunEx would be called in the application.
RunEx("notepad.exe", "xxx.txt", 1)