@@ -11,6 +11,8 @@ Unicode true
1111!include x64.nsh
1212!include WordFunc.nsh
1313!include " StrFunc.nsh"
14+ !include " Win\COM.nsh"
15+ !include " Win\Propkey.nsh"
1416${StrCase}
1517${StrLoc}
1618
@@ -449,7 +451,7 @@ Section WebView2
449451 !if " ${INSTALLWEBVIEW2MODE}" == " downloadBootstrapper"
450452 Delete " $TEMP\MicrosoftEdgeWebview2Setup.exe"
451453 DetailPrint " $(webview2Downloading)"
452- nsis_tauri_utils ::download " https://go.microsoft.com/fwlink/p/?LinkId=2124703" " $TEMP\MicrosoftEdgeWebview2Setup.exe"
454+ NSISdl ::download " https://go.microsoft.com/fwlink/p/?LinkId=2124703" " $TEMP\MicrosoftEdgeWebview2Setup.exe"
453455 Pop $0
454456 ${If} $0 == 0
455457 DetailPrint " $(webview2DownloadSuccess)"
@@ -1148,12 +1150,12 @@ Section Install
11481150 CreateDirectory " $INSTDIR\\{{this}}"
11491151 {{/each}}
11501152 {{# each resources}}
1151- File /a " /oname={{this.[1]}}" " {{@key}}"
1153+ File /a " /oname={{this.[1]}}" " {{unescape-dollar-sign @key}}"
11521154 {{/each}}
11531155
11541156 ; Copy external binaries
11551157 {{# each binaries}}
1156- File /a " /oname={{this}}" " {{@key}}"
1158+ File /a " /oname={{this}}" " {{unescape-dollar-sign @key}}"
11571159 {{/each}}
11581160
11591161 ; Create uninstaller
@@ -1199,7 +1201,6 @@ Section Install
11991201
12001202 ; Auto close this page for passive mode
12011203 ${IfThen} $PassiveMode == 1 ${|} SetAutoClose true ${|}
1202-
12031204 Call SetupPhcode
12041205SectionEnd
12051206
@@ -1212,7 +1213,8 @@ Function .onInstSuccess
12121213 check_r_flag:
12131214 ${GetOptions} $CMDLINE " /R" $R0
12141215 IfErrors run_done 0
1215- Exec ' "$INSTDIR\${MAINBINARYNAME}.exe"'
1216+ ${GetOptions} $CMDLINE " /ARGS" $R0
1217+ Exec ' "$INSTDIR\${MAINBINARYNAME}.exe" $R0'
12161218 run_done:
12171219FunctionEnd
12181220
@@ -1226,6 +1228,35 @@ Function un.onInit
12261228 !insertmacro MUI_UNGETLANGUAGE
12271229FunctionEnd
12281230
1231+ !macro DeleteAppUserModelId
1232+ !insertmacro ComHlpr_CreateInProcInstance ${CLSID_DestinationList} ${IID_ICustomDestinationList} r1 " "
1233+ ${If} $1 P<> 0
1234+ ${ICustomDestinationList::DeleteList } $1 ' ("${BUNDLEID}")'
1235+ ${IUnknown::Release } $1 " "
1236+ ${EndIf}
1237+ !insertmacro ComHlpr_CreateInProcInstance ${CLSID_ApplicationDestinations} ${IID_IApplicationDestinations} r1 " "
1238+ ${If} $1 P<> 0
1239+ ${IApplicationDestinations::SetAppID } $1 ' ("${BUNDLEID}")i.r0'
1240+ ${If} $0 >= 0
1241+ ${IApplicationDestinations::RemoveAllDestinations } $1 ' '
1242+ ${EndIf}
1243+ ${IUnknown::Release } $1 " "
1244+ ${EndIf}
1245+ !macroend
1246+
1247+ ; From https://stackoverflow.com/a/42816728/16993372
1248+ !macro UnpinShortcut shortcut
1249+ !insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r0 " "
1250+ ${If} $0 P<> 0
1251+ System::Call ' SHELL32::SHCreateItemFromParsingName(ws, p0, g "${IID_IShellItem}", *p0r1)' " ${shortcut}"
1252+ ${If} $1 P<> 0
1253+ ${IStartMenuPinnedList::RemoveFromList } $0 ' (r1)'
1254+ ${IUnknown::Release } $1 " "
1255+ ${EndIf}
1256+ ${IUnknown::Release } $0 " "
1257+ ${EndIf}
1258+ !macroend
1259+
12291260Function un.CleanPhcode
12301261; NSIS Cleanup Script
12311262
@@ -1668,15 +1699,17 @@ Section Uninstall
16681699 ; Delete uninstaller
16691700 Delete " $INSTDIR\uninstall.exe"
16701701
1671- ${If} $DeleteAppDataCheckboxState == 1
1672- RMDir /R /REBOOTOK " $INSTDIR"
1673- ${Else}
1674- {{# each resources_ancestors}}
1675- RMDir /REBOOTOK " $INSTDIR\\{{this}}"
1676- {{/each}}
1677- RMDir " $INSTDIR"
1678- ${EndIf}
1702+ {{# each resources_ancestors}}
1703+ RMDir /REBOOTOK " $INSTDIR\\{{this}}"
1704+ {{/each}}
1705+ RMDir " $INSTDIR"
1706+
1707+ !insertmacro DeleteAppUserModelId
1708+ !insertmacro UnpinShortcut " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
1709+ !insertmacro UnpinShortcut " $DESKTOP\${MAINBINARYNAME}.lnk"
1710+
16791711 Call un.CleanPhcode
1712+ ; Remove start menu shortcut
16801713 !insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
16811714 Delete " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
16821715 RMDir " $SMPROGRAMS\$AppStartMenuFolder"
@@ -1717,13 +1750,39 @@ Function SkipIfPassive
17171750 ${IfThen} $PassiveMode == 1 ${|} Abort ${|}
17181751FunctionEnd
17191752
1753+ !macro SetLnkAppUserModelId shortcut
1754+ !insertmacro ComHlpr_CreateInProcInstance ${CLSID_ShellLink} ${IID_IShellLink} r0 " "
1755+ ${If} $0 P<> 0
1756+ ${IUnknown::QueryInterface } $0 ' ("${IID_IPersistFile}",.r1)'
1757+ ${If} $1 P<> 0
1758+ ${IPersistFile::Load } $1 ' ("${shortcut}", ${STGM_READWRITE})'
1759+ ${IUnknown::QueryInterface } $0 ' ("${IID_IPropertyStore}",.r2)'
1760+ ${If} $2 P<> 0
1761+ System::Call ' Oleaut32::SysAllocString(w "${BUNDLEID}") i.r3'
1762+ System::Call ' *${SYSSTRUCT_PROPERTYKEY}(${PKEY_AppUserModel_ID})p.r4'
1763+ System::Call ' *${SYSSTRUCT_PROPVARIANT}(${VT_BSTR},,&i4 $3)p.r5'
1764+ ${IPropertyStore::SetValue } $2 ' ($4,$5)'
1765+
1766+ System::Call ' Oleaut32::SysFreeString($3)'
1767+ System::Free $4
1768+ System::Free $5
1769+ ${IPropertyStore::Commit } $2 " "
1770+ ${IUnknown::Release } $2 " "
1771+ ${IPersistFile::Save } $1 ' ("${shortcut}",1)'
1772+ ${EndIf}
1773+ ${IUnknown::Release } $1 " "
1774+ ${EndIf}
1775+ ${IUnknown::Release } $0 " "
1776+ ${EndIf}
1777+ !macroend
1778+
17201779Function CreateDesktopShortcut
17211780 CreateShortcut " $DESKTOP\${MAINBINARYNAME}.lnk" " $INSTDIR\${MAINBINARYNAME}.exe"
1722- ApplicationID::Set " $DESKTOP\${MAINBINARYNAME}.lnk" " ${BUNDLEID} "
1781+ !insertmacro SetLnkAppUserModelId " $DESKTOP\${MAINBINARYNAME}.lnk"
17231782FunctionEnd
17241783
17251784Function CreateStartMenuShortcut
17261785 CreateDirectory " $SMPROGRAMS\$AppStartMenuFolder"
17271786 CreateShortcut " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk" " $INSTDIR\${MAINBINARYNAME}.exe"
1728- ApplicationID::Set " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk" " ${BUNDLEID} "
1787+ !insertmacro SetLnkAppUserModelId " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME}.lnk"
17291788FunctionEnd
0 commit comments