I have a batch file that I need to run within my NSIS installer. It must run after all the files have been extracted, (I suppose this is obvious, otherwise the batch file wouldn't exist yet).
I tried to use MUI_PAGE_CUSTOMFUNCTION_PRE with the finish page in order to run it but when it gets to that portion of the script it appears that it skips right over it. Below is how I invoke it.
;;Finish Page
!define MUI_PAGE_CUSTOMFUNCTION_PRE Done
!insertmacro MUI_PAGE_FINISH
Function Done
ExecWait '"$INSTDIR\BatchFile" "$INSTDIR" "$DATA_FOLDER"'
FunctionEnd
Thanks in advance for your help.
UPDATE
I have now tried using the following:
ExpandEnvStrings $0 %COMSPEC%
ExecWait '"$0" /C "$INSTDIR\batch.bat" "$INSTDIR" "$DATA_FOLDER"'
This did not work, so I took out the /C to see what the cmd prompt was saying (it is popping up, but closing immediately) and it seems as though it executes cmd.exe but that's it, it doesn't complete the rest of the execute.
UPDATE #2
The core knowledge that led to me getting it to work can be found here:
Windows batch files: .bat vs .cmd?
For whatever reason .bat files do not agree with ExecWait.
In the end:
ExecWait '"$INSTDIR\BatchFile.cmd" "$INSTDIR" "$DATA_FOLDER"'
Worked just fine.
Exec[Wait] needs proper quoting:
ExpandEnvStrings $0 %COMSPEC%
ExecWait '"$0" /C "c:\path\to\batch.cmd" "quoted param" normalparam "c:\last param"'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With