I am new to NSIS I am trying to add two install commands that will add registry values for my app, the end goal is for those values to look like this: "path\to\executable" "%1"
The problem is that NSIS does not accept any format for this end result:
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr HKCR '.acmi\\OpenWithProgids' 'MyApp.myext' ''
WriteRegStr HKCR 'Applications\\MyApp.exe\\shell\\open\\command' '' '\"$INSTDIR\\bin\\MyApp.exe\" \"%1\"'
")
This results into the weird value ;$INSTDIR\bin\MyApp.exe" "%1; where the first and last " are turned into ;
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr HKCR '.acmi\\OpenWithProgids' 'MyApp.myext' ''
WriteRegStr HKCR 'Applications\\MyApp.exe\\shell\\open\\command' '' '\\\"$INSTDIR\\bin\\MyApp.exe\" \"%1\\\"'
")
This will do "$INSTDIR\bin\MyApp.exe;%1" so again the first and last unescaped " will turn into ; and also I have the extra \ at the beggining and end
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr HKCR '.acmi\\OpenWithProgids' 'MyApp.myext' ''
WriteRegStr HKCR 'Applications\\MyApp.exe\\shell\\open\\command' '' '\\\"$INSTDIR\\bin\\MyApp.exe\\\" \\\"%1\\\"'
")
Escaping all " will result in no ; but the exta \ will still break the path...
What should be done to get the wanted end result? "path\to\executable" "%1"
EDIT:
For anyone following in the future what worked is moving the WriteRegStr commands to a separate .nsh file and set CPACK_NSIS_EXTRA_INSTALL_COMMANDS to include the file
NSIS_registry.nsh
WriteRegStr HKCR ".acmi\OpenWithProgids" "MyApp.myext" ""
WriteRegStr HKCR "Applications\MyApp.exe\shell\open\command" "" '"$INSTDIR\bin\MyApp.exe" "%1"'
CMakeLists.txt
...
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
!include ${CMAKE_SOURCE_DIR}\\NSIS_registry.nsh
")
...