Skip to content
⌘ NSIS Forum Archive

How run bat file with arguments using nsis

9 posts

dinesh.guntha#

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.
Anders#
Your quoting is also wrong, the nsExec readme has a very clear example:
nsExec::ExecToStack [OPTIONS] '"PATH" param1 param2 paramN'
dinesh.guntha#
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#
I wouldn't be surprised if that doesn't work for users who've set 'Edit' as the default operation to .bat files.
Anders#
Originally Posted by MSG View Post
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#
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"`