dinesh.guntha
31st January 2012 09:06 UTC
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.
MSG
31st January 2012 10:59 UTC
You're not using $0...
Anders
31st January 2012 11:18 UTC
Your quoting is also wrong, the nsExec readme has a very clear example:
nsExec::ExecToStack [OPTIONS] '"PATH" param1 param2 paramN'
dinesh.guntha
1st February 2012 12:57 UTC
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"'
MSG
1st February 2012 16:16 UTC
I wouldn't be surprised if that doesn't work for users who've set 'Edit' as the default operation to .bat files.
Anders
2nd February 2012 09:55 UTC
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%
Lloigor
4th February 2012 17:57 UTC
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"`
MSG
5th February 2012 09:42 UTC
Lloigor: You should use COMSPEC, not cmd.exe.
Lloigor
6th February 2012 02:16 UTC
Yes, you're right.. macro updated.