Archive: !insertmacro and single quotes


!insertmacro and single quotes
I have tried to write script that
has a function and an accompanying macro:

Function __WriteBatFile
...
FunctionEnd

!macro WriteBatFile filename commands
Push "${commands}"
Push "${filename}"
Call __WriteBatFile
!macroend

!insertmacro WriteBatFile "$INSTDIR\afile.bat" '"$INSTDIR\afile.exe" /S'

but when I use strings that have spaces, I get an error message from makensis saying:

!insertmacro: WriteBatFile
Push expects 1 parameter got 5.
Usage: Push string
Error in macro WriteBatFile on macroline 1

I have tried many combinations of single and double quotes and only the number of arguments changes. I have also tried $\". It seems as though !insertmacro only looks for double quotes and interprets everything else literally.
If someone could enlighten me I would greatly appreciate it.


You've got this command in your macro: Push "${commands}"

Now you set the commands define to "$INSTDIR\afile.exe" /S

You will get: Push ""$INSTDIR\afile.exe" /S"

So, instead, use:

!insertmacro WriteBatFile "$INSTDIR\afile.bat" "$\"$INSTDIR\afile.exe$\" /S"