calling a batch file with parameters
Hi,
I am trying to call a batch file that I created. The batch file parameter is the installed directory .
I did the following steps:
1. attached the batch file to the installation.
2. created a custom action of exectue program from installation.
3. executable file: [systemfolder]cmd.exe
4. the command line arguments is:
/c location_of-the_batch_file_in_installation\batch_file_name.bat parameter_passed_to_the_batch_file
parameter_passed_to_the_batch_file=[INSTALLDIR] (usually C:\Program Files\...)
I think that the problem is because the space between the Program and the Files is making trouble.
how can I pass the parameter the batch will succeed ?
the batch file works properly if I call it from the command line in dos, but from the msi it failed.
Need you help,
thanks, Ido
Where are you calling the batch file?
Where are you calling the batch file? If in the deferred sequence, then [INSTALLDIR] will not have a value.
Have you tried using "[INSTALLDIR]" (ie with double quotes around it), if the location is not in the deferred sequence)?
What are you using the batch file for?
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Try: parameter_passed_to_the_
Try:
parameter_passed_to_the_batch_file="[INSTALLDIR]"
I tried to pass
I tried to pass parameter_passed_to_the_batch_file="[INSTALLDIR]"
it doesn't succeed. the msi fails on that batch file.
if the [INSTALLDIR]="c:\" it succeed.
that is to say that the problem is the space in "program files".
another ideas how to pass a parameter with a space in the middle to command line ?
thanks Ido
It sounds like it is the
It sounds like it is the batch file itself that cannot parse the long file name. Windows cmd.exe does understand quoted long file names.
Possible solution
How about using a Wisescript custom action to launch your batch file?
Wisescript has a function on the "Set Variable" command which converts longfilename format to shortfilename format.
So you could read the [INSTALLDIR] property into a Wisescript variable, convert the wisescript variable into a shortfilename, then use the Execute Program command in Wisescript to run %SYS32%\CMD.EXE /C yourbatchfile %YOURSHORTFILENAMEFORINSTALLDIR%
Since the Execute Program command in Wisescript has an option to run in a hidden window, this may offer you a solution to your problem in the other thread you posted, about hiding the cmd window.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Thanks for your answer. I
Thanks for your answer.
I haven't worked with wisescript.
I would appriciate if you can describe to me a little more what should I do to create a wisescript and run it and how can I pass the [INSTALLDIR] and run it silently.
thanks, Ido
Which Wise tool are you using?
It would help to know which Wise tool you are using as this may affect what I tell you...
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
I am using wise installation
I am using wise installation studio 7.0
I succeeded to create a wisescript but it still not works. I think because it doesn't get the parameters from the msi correctly.
I did that:
Get Windows Installer Property [INSTALLDIR] into INSTALLEDDIR
Set Variable INSTALLEDDIR to INSTDIR
Get Windows Installer Property [OFFLINE] into OFFLINEDIR
Set Variable OFFLINEDIR to OFDIR
Execute %SYS32%\cmd.exe /c %OFDIR%CopyOffline.bat %INSDIR%
by the way for understanding:
[OFFLINE] = [INSTALLDIR]\Bin\Offline
[INSTALLDIR] = the installed dir (as you know..)
(the operation in the set variable is convert to short file name as you wrote).
by the way, can I debug the wisescript during the debug of the installation (I tried to put break point in the wisescript and it doesn't stop there)
thanks a lot,
Ido
Your code is wrong
Get Windows Installer Property [INSTALLDIR] into INSTALLEDDIR
Set Variable INSTALLEDDIR to %INSTALLEDDIR% (with the option enabled to convert to shortfilename)
Get Windows Installer Property [OFFLINE] into OFFLINEDIR
Set Variable OFFLINEDIR to %OFFLINEDIR% (with the option enabled to convert to shortfilename)
Execute %SYS32%\cmd.exe /c %OFFLINEDIR%CopyOffline.bat %INSTALLEDDIR%
(By the way, there was a typo in your code also: Execute %SYS32%\cmd.exe /c %OFDIR%CopyOffline.bat %INSDIR%<--- it should be %INSTDIR% for consistency with your earlier code. Make sure you don't have typos in the corrected code otherwise it will cause you more problems!!)
By the way, the debug option is not much use in this situation as you can't debug this code when it is running as a custom action outside the wisescript editor, unless you replace the "Get Windows Installer Property" commands with a Set Variable command to hard code the value.
For testing, I normally use the Display Message command to display the variables - just add %OFFLINEDIR% and %INSTALLEDDIR% to a Display Message command, inserted after each operation where you convert to short file name - that way you can check if the short file name is resolved correctly and has a trailing backslash, etc
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Thanks a lot. I learnt
Thanks a lot. I learnt something new.
It works.
Ido
Would you like to reply?
Login or Register to post your comment.