This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Dumb Question
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 10, 2009
04:11 AM
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.
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.
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 10, 2009
02:01 PM
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;
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;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 10, 2009
02:54 PM
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.
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 01, 2009
04:02 PM
Sorry about my utter ignorance, but how can I use InstallScript to run a BAT file?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 02, 2009
12:51 PM
There is an example of working code to do this higher up in the post.