Setup Factory 10

File.Run

File.Run

This is the first topic This is the last topic  

File.Run

This is the first topic This is the last topic  

OverviewExamples

number File.Run (

string Filename,

string Args = "",

string WorkingFolder = "",

number WindowMode = SW_SHOWNORMAL,

boolean WaitForReturn = false )

Example 1

ReturnCode = File.Run(_TempFolder.."\\setup.exe", "/w", "", SW_MAXIMIZE, true);

Runs "setup.exe" located in the user's Temp folder, passes it /w as a command line argument, tells it to open with its window maximized, and waits for setup.exe to exit before continuing with the next action.  Any code returned by "setup.exe" is stored in variable "ReturnCode".

Note: _TempFolder is a built-in variable that contains the path to the user's system "Temp" folder.

Example 2

File.Run("notepad.exe", _SourceFolder.."\\Docs\\readme.txt", "C:\\Temp", SW_SHOWNORMAL, true);

Runs notepad.exe and opens "Docs\readme.txt" in it which is located in the source folder. Specifies C:\Temp as the working directory, tells notepad to open with its normal window size and position, and waits for the user to close notepad.exe before continuing.

Note: _SourceFolder is a built-in variable that contains the path to the folder where the setup.exe file is located.

Example 3

-- Confirm that the installation executable should be launched.

result = Dialog.Message("Confirm", "Are you sure you would like to install now?", MB_YESNO, MB_ICONINFORMATION, MB_DEFBUTTON1);

 

-- If the user clicked the Yes button.

if (result == IDYES) then

 

   -- Run the installation file.

   File.Run(_TempFolder.."\\Second_Install\\setup.exe", "", "", SW_SHOWNORMAL, false);

 

   -- Check to see if an error occurred when launching the file.

   error = Application.GetLastError();

 

   -- If an error occurred, display an error message to the user.

   if (error ~= 0) then

       Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);

   end

end

Asks the user if they would like to run the installation file. If they click the Yes button, the installation file will be launched using the File.Run action. If the action fails, the error code message is displayed in a dialog message.

Example 4

-- Get the session variable and assign it to a regular variable

AppDir = SessionVar.Expand("%AppFolder%");

 

-- Run the file using the AppDir variable

File.Run(AppDir.."\\Myfile.exe", "", "", SW_SHOWNORMAL, false);

 

-- This could also be done as such

File.Run(SessionVar.Expand("%AppFolder%").."\\Myfile.exe", "", "", SW_SHOWNORMAL, false);

This example shows two ways of using a File.Run action with a session variable.

See also: Related Actions


Learn More: Indigo Rose Software - Setup Factory - Buy Now - Contact Us