cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
logesh1402
Level 3

LanchApplication doesn't work in rare case

hi 
  we are using install-script project for creating executable's. Install-shield fails to invoke a batch script from SUPPORTDIR and it's a rare case scenario. Below is the function used in our install-script project which invokes the batch file from SUPPORTDIR.

 

function BOOL unpack()
STRING batname, cmdargs, svLogFileName, svInsDir,ExeFile,LogsDir,szDirectory;                             
NUMBER nvExitCode,NRet;
begin		
	if ( SYSINFO.WIN9X.bWin9X )
        then
            CMDPROMPT = "command.com";
	else
            CMDPROMPT = "cmd.exe";
	endif;
	 
	batname = SUPPORTDIR ^ "unpack.bat";
	LongPathToQuote(batname,TRUE);
		
	svLogFileName=TARGETDIR ^ "unpack.txt";
	LongPathToQuote(svLogFileName,TRUE);
        
        szDirectory=TARGETDIR;
        LongPathToQuote(szDirectory,TRUE);

	cmdargs = batname+" "+szDirectory+" > "+svLogFileName+ " 2>&1";
	
	nvExitCode=LaunchApplication(CMDPROMPT," /C "+cmdargs,SUPPORTDIR,SW_HIDE,60000,LAAW_OPTION_WAIT);
	
        NRet=LAAW_PARAMETERS.nLaunchResult; 
											
	
	if(NRet=1)
	then
		return FALSE;
	else
		return TRUE;
	endif;


return TRUE;

end;

 

Batch script unpack.bat

 

@ echo ON

set PRO_HOME=%~1

if x"%PRO_HOME%"==x  (
 echo home not set
 exit 2;
)

if NOT EXIST "%PRO_HOME%" exit 3

cd /D "%PRO_HOME%"

call "%PRO_HOME%\init.bat"

exit %ERRORLEVEL%

 

ERROR logged in unpack.txt:

 

'C:\Users\test~1\AppData\Local\Temp\{50849220-F22D-46F7-8101-D34FF50A19E6}\{BCEC963-6E2D-4196-L310-5KE3B31937A9}\unpack.bat' is not recognized as an internal or external command,
operable program or batch file.

 

 

There is no doubt batch script is present in SUPPORTDIR. we could not find any concrete reason behind this error.

In Most of the cases either we got the above error or in the worst case , log will not be created in TARGETDIR and fails with return code 1.

Install-shield version - 2018.
Project type - Install-script
Platform- occurs in all OS ,server as well as client.


Any help is appreciated.

Thanks,
logesh

Spoiler

 

 

Labels (2)
0 Kudos
(4) Replies
logesh1402
Level 3

@SpiderLily1  any guess?

0 Kudos

I have not actually done this before.  I'm wondering why you need to launch a command prompt at all.  Can you just launch the .bat directly?  Also, maybe try LaunchAppAndWait instead of LaunchApplication?

Thanks a lot for your suggestion @SpiderLily1 . can you give a simple snippet on invoking a  batch script directly using LaunchAppandWait

0 Kudos