cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
virenque
Level 2

batch file with parameter

Hi!

I am very frustrated! I only want to make a custom action that works with parameters! When I make a custom action that looks like this cmd.exe /c "[INSTALLDIR]test.bat" it works! So now it is possible to give the batch file a paramter! This should look like this cmd.exe /c "[INSTALLDIR]test.bat" "[INSTALLDIR]". This doesn't work. How can IS deal with such parameters! Has anyone an idea! Please help! Any help would be appreciated!
Thank you!

Roland

Update: I am one step further! It nearly works when I set the following command: cmd.exe /c "[INSTALLDIR]test.bat" [INSTALLDIR] Then I get in the bat File the C:\Program! The only problem is it must be C:\Program Files! Any help would be appreciated.
Labels (1)
0 Kudos
(4) Replies
buogr01
Level 4

I do things like this all the time. I do it with calls similar to below. Hope this helps & sorry that the formatting gets kind of messy.


szCmd = "cmd.exe" ;
LongPathToQuote(szCmd,TRUE);
szParam = "/c cmd /c CreateSQLServerLogins.bat " + szJavaHome +" " + _LOGFILEDIR ^ _CMDLOGFILENAME + " \"" +szUserPassword+ "\" \"" + szDBMSUser + "\" \"" + szDBMSPassword + "\" " + szDBMSServer + " " + szDBMSPort + " " + szDBMSInstance ;

szLogParam = "/c cmd /c CreateSQLServerLogins.bat " + szJavaHome +" " + _LOGFILEDIR ^ _CMDLOGFILENAME + " \"********\" " +szDBMSUser +" \"********\" " + szDBMSServer + " " + szDBMSPort + " " + szDBMSInstance ;

ChangeDirectory(SUPPORTDIR);
writeLog("Launching CreateSQLServerLogins");
writeLog("Command is: " + szCmd + " " + szLogParam);


nResult = LaunchAppAndWait(szCmd,szParam,LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN);
if (nResult != 0) then
NumToStr(szErrorStr,nResult);
writeLog ( "Unable to launch CreateSQLServerLogins.bat" );
writeLog ( "Command was: " + szCmd + " " + szLogParam );
writeLog ( "Error " + szErrorStr + ": " + FormatMessage(nResult) );
return nResult;
endif;
nResult = LAAW_PARAMETERS.nLaunchResult;
if (nResult != 0) then
NumToStr(szErrorStr,nResult);
writeLog ( "Error " + szErrorStr );
writeLog ( "CreateSQLServerLogins completed with errors" );
return nResult;
endif;
0 Kudos
buogr01
Level 4

I re-read your post and my response again and I'm not exactly sure I answered what you were looking for. If you are trying to get back C:\Program Files\ and you are getting C:\Program this is likely an error due to the spacing. You can do a few things....
1. You can surround the whole patch in quotes.
INSTALLDIR is set. (Pre-defined Constant).
szTmpInstallDir = INSTALLDIR;
szTmpInstallDir = "\"szTmpInstallDir\""; //This surrounds the paths in quotes.

2. Conversely you can do something like this:

LongPathToShort(szTmpInstallDir);

The issue is bat files don't handle paths with spaces without the path being quoted or using the 8.3 naming convention.

Hope that helps.
0 Kudos
Lord_Sammael
Level 3

Sorry about my utter ignorance, but how can I use InstallScript to run a BAT file?
0 Kudos
buogr01
Level 4

There is an example of working code to do this higher up in the post.
0 Kudos