Archive: How run bat file with arguments using nsis


How run bat file with arguments using nsis
Hi All,

ExpandEnvStrings $0 %COMSPEC%
nsExec::ExecToStack "D:\dinesh\jdk7samples\JavaApplication2\dist\jasypt.bat" "$db_password_state"

I am running this for the batch file but it is not running any one can help.


You're not using $0...


Your quoting is also wrong, the nsExec readme has a very clear example:

nsExec::ExecToStack [OPTIONS] '"PATH" param1 param2 paramN'

Thanks for helping.
It is working , i used this statment
ExecWait '"D:\dinesh\jdk7samples\JavaApplication2\dist\Jasypt.bat" "$db_password_state" "$INSTDIR\jre6\pass.txt"'


I wouldn't be surprised if that doesn't work for users who've set 'Edit' as the default operation to .bat files.


Originally posted by MSG
I wouldn't be surprised if that doesn't work for users who've set 'Edit' as the default operation to .bat files.
That only applies to ShellExecute, not CreateProcess (used by nsExec) but it probably relies on a correct %PATHEXT%

If you need to execute with cmd.exe, you can use:
ExecWait `"$SYSDIR\cmd.exe" /c "D:\dinesh\jdk7samples\JavaApplication2\dist\Jasypt.bat" "$db_password_state" "$INSTDIR\jre6\pass.txt"`

There's also this simple macro: http://nsis.sourceforge.net/CmdExec
It uses cmd.exe to execute a command and its parameters, with working dir, optional dospause, stayinprompt and execwait:

${CmdWait} "" `"D:\dinesh\jdk7samples\JavaApplication2\dist\Jasypt.bat" "$db_password_state" "$INSTDIR\jre6\pass.txt"`


Lloigor: You should use COMSPEC, not cmd.exe.


Yes, you're right.. macro updated.