Reputation: 17425
I have a batch file install_license.bat
which installs licences for our software. The batch file simply runs a java class which does what is needed. And the batch file needs two parameters, action install and path to licence file which in turn are passed to the java class.
C:\MySoftware\install_license.bat install "D:\documents\myLicense.lic"
As part of our installer, we want to give an option to user to enter the path to licence. If user enters a path, above batch file should run as part of installation process and if not, then license installation should be skipped i.e. above batch should not run.
I know how to fire a batch from within installer.
However, the java program which actually installs the license gives a prompt to the user in the lines of:
Continue with license file installation? [y/N]
Based on user entering yes
or no
, the installation of license file continues. I do not have control over how this java class is working and I can not modify that.
Is there a way to handle this case from NSIS. That is, when running the batch, NSIS passes "y" to continue installation of the license file?
Here is the bat file:
@REM install_license.bat
@ECHO off
setlocal
set CMD_LINE_ARGS=
REM Gather all command line switches
:next_parm
IF [%1] == [] GOTO break_parm
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
SHIFT /1
GOTO next_parm
:break_parm
set LICENSE_PARAMETER=-Dinstalled.licenses.file="%INSTALLED_LICENSE_PATH%"
call "%_MY_JAVA%" %LICENSE_PARAMETER% -DCONSOLE_HOME=. -Dlog4j.configuration=log4j.xml -cp %CLASSPATH% org.somepackage.MyClass %CMD_LINE_ARGS%
endlocal
Upvotes: 1
Views: 278
Reputation:
To send a default result to most internal cmd
commands and some external commands you simply need to echo the result and pipe it to the command:
echo y|call "%_MY_JAVA%" %LICENSE_PARAMETER% -DCONSOLE_HOME=. -Dlog4j.configuration=log4j.xml -cp %CLASSPATH% org.somepackage.MyClass %CMD_LINE_ARGS%
Upvotes: 1