Monday, March 11, 2013

How to run an exe with InstallScript

The script below will run an exe. 

prototype runEXE(STRING);  
function runEXE(exe) 
string fullPath;
begin     
    if(FeatureIsItemSelected(MEDIA, "Server") == TRUE) then
        fullPath = TARGETDIR^exe;
        LAAW_STARTUPINFO.dwFlags = LAAW_STARTUPINFO.dwFlags | STARTF_USESHOWWINDOW;
        LAAW_STARTUPINFO.wShowWindow = FALSE;
        if(LaunchAppAndWait(fullPath, "", LAAW_OPTION_WAIT) < 0)then
            MessageBox("Error launching " + exe + ". Check if it exists in " + TARGETDIR + " then manually launch it" , INFORMATION);
        endif;                 
    endif;   
end;


How to call it
The script below checks if the "Server" feature is being installed, and then calls runEXE on two files: test.bat and modifyConfig.exe.

 function OnEnd( )
begin  
    if(FeatureIsItemSelected(MEDIA, "Server") == TRUE) then
        runEXE("test.bat");
        runEXE("modifyConfig.exe");
   endif;    
end;

No comments:

Post a Comment

There was an error in this gadget