1+ !include MUI2.nsh
2+ !include LogicLib.nsh
3+ !include x64.nsh
4+
5+ # The install path is hardcoded.
6+ # We need both a x64 and x86 OpenWith.exe and putting both
7+ # in Program Files won't work. Having two directory choices
8+ # would also be a mess.
9+
10+ Name " OpenWithEx"
11+ Outfile " build\OpenWithEx-setup-x64.exe"
12+ RequestExecutionLevel admin
13+
14+ !define MUI_ICON " installer.ico"
15+ !define MUI_UNICON " installer.ico"
16+ !define MUI_WELCOMEFINISHPAGE_BITMAP " welcome.bmp"
17+ !define MUI_UNWELCOMEFINISHPAGE_BITMAP " welcome.bmp"
18+ !define MUI_ABORTWARNING
19+ !define MUI_UNABORTWARNING
20+ !define MUI_FINISHPAGE_NOAUTOCLOSE
21+ !define MUI_UNFINISHPAGE_NOAUTOCLOSE
22+
23+ !insertmacro MUI_PAGE_WELCOME
24+ !insertmacro MUI_PAGE_LICENSE " ..\LICENSE"
25+ !insertmacro MUI_PAGE_COMPONENTS
26+ !insertmacro MUI_PAGE_INSTFILES
27+ !insertmacro MUI_PAGE_FINISH
28+
29+ !insertmacro MUI_UNPAGE_WELCOME
30+ !insertmacro MUI_UNPAGE_CONFIRM
31+ !insertmacro MUI_UNPAGE_INSTFILES
32+ !insertmacro MUI_UNPAGE_FINISH
33+
34+ !insertmacro MUI_LANGUAGE " English"
35+
36+ Section " OpenWithEx" OpenWithEx
37+ # Required
38+ SectionIn RO
39+
40+ # NSIS produces an x86-32 installer. Deny installation if
41+ # we're not on a x86-64 system running WOW64.
42+ ${IfNot} ${RunningX64}
43+ MessageBox MB_OK |MB_ICONSTOP " OpenWithEx does not support 32-bit systems."
44+ Quit
45+ ${EndIf}
46+
47+ # Make sure install directories are clean
48+ RMDir /r " $PROGRAMFILES64\OpenWithEx"
49+ RMDir /r " $PROGRAMFILES32\OpenWithEx"
50+
51+ # Install x86-64 files
52+ SetOutPath " $PROGRAMFILES64\OpenWithEx"
53+ WriteUninstaller " $PROGRAMFILES64\OpenWithEx\uninstall.exe"
54+ File " ..\build\Release-x64\OpenWith.exe"
55+ File " ..\build\Release-x64\config\OpenWithExConfig.exe"
56+
57+ # Install x86-32 files
58+ SetOutPath " $PROGRAMFILES32\OpenWithEx"
59+ File " ..\build\Release-Win32\OpenWith.exe"
60+
61+ # Create configurator shortcut
62+ SetShellVarContext all
63+ CreateDirectory " $SMPROGRAMS\OpenWithEx"
64+ CreateShortCut " $SMPROGRAMS\OpenWithEx\Configure OpenWithEx.lnk" \
65+ " $PROGRAMFILES64\OpenWithEx\OpenWithExConfig.exe"
66+
67+ # Create Uninstall entry
68+ SetRegView 64
69+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
70+ " DisplayName" " OpenWithEx"
71+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
72+ " DisplayIcon" " $PROGRAMFILES64\OpenWithEx\OpenWith.exe,0"
73+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
74+ " UninstallString" " $\" $PROGRAMFILES64\OpenWithEx\uninstall.exe$\" "
75+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
76+ " Publisher" " aubymori"
77+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
78+ " DisplayVersion" " 1.0.0"
79+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
80+ " NoModify" 1
81+ WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx" \
82+ " NoRepair" 1
83+
84+ # Make Open With use our server
85+ ReadEnvStr $0 " USERNAME"
86+ AccessControl::SetRegKeyOwner HKCR " CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0
87+ AccessControl::GrantOnRegKey HKCR " CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0 FullAccess
88+ WriteRegExpandStr HKCR " CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" \
89+ " " " $PROGRAMFILES64\OpenWithEx\OpenWith.exe"
90+ AccessControl::SetRegKeyOwner HKCR " WOW6432Node\CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0
91+ AccessControl::GrantOnRegKey HKCR " WOW6432Node\CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0 FullAccess
92+ WriteRegExpandStr HKCR " WOW6432Node\CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" \
93+ " " " $PROGRAMFILES32\OpenWithEx\OpenWith.exe"
94+ SectionEnd
95+
96+ !macro InstallLang lang
97+ SetOutPath " $PROGRAMFILES64\OpenWithEx\${lang}"
98+ File " ..\build\Release-x64\${lang}\OpenWith.exe.mui"
99+ SetOutPath " $PROGRAMFILES32\OpenWithEx\${lang}"
100+ File " ..\build\Release-Win32\${lang}\OpenWith.exe.mui"
101+ !macroend
102+
103+ SectionGroup " Languages"
104+ Section " English (United States)"
105+ SectionIn RO
106+ !insertmacro InstallLang " en-US"
107+ SectionEnd
108+ SectionGroupEnd
109+
110+ Section " Uninstall"
111+ # Delete files
112+ RMDir /r " $PROGRAMFILES64\OpenWithEx"
113+ RMDir /r " $PROGRAMFILES32\OpenWithEx"
114+
115+ # Delete config shortcut
116+ SetShellVarContext all
117+ RMDir /r " $SMPROGRAMS\OpenWithEx"
118+
119+ # Revert to default OpenWith server.
120+ SetRegView 64
121+ ReadEnvStr $0 " USERNAME"
122+ AccessControl::SetRegKeyOwner HKCR " CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0
123+ AccessControl::GrantOnRegKey HKCR " CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0 FullAccess
124+ WriteRegExpandStr HKCR " CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" \
125+ " " " %SystemRoot%\system32\OpenWith.exe"
126+ AccessControl::SetRegKeyOwner HKCR " WOW6432Node\CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0
127+ AccessControl::GrantOnRegKey HKCR " WOW6432Node\CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" $0 FullAccess
128+ WriteRegExpandStr HKCR " WOW6432Node\CLSID\{e44e9428-bdbc-4987-a099-40dc8fd255e7}\LocalServer32" \
129+ " " " %SystemRoot%\system32\OpenWith.exe"
130+
131+ # Delete uninstall entry
132+ DeleteRegKey HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenWithEx"
133+ SectionEnd
0 commit comments