This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.nsi
executable file
·120 lines (90 loc) · 3.96 KB
/
installer.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
; Scaffolding by https://github.com/idleberg/NSIS-Sublime-Text
; Settings ---------------------------------
Name "NSIS Context Menu for Windows 7"
OutFile "Context_Menu.exe"
RequestExecutionLevel admin
InstallDir $PROGRAMFILES\NSIS
InstallDirRegKey HKLM Software\NSIS ""
!include LogicLib.nsh
; Pages ------------------------------------
Page directory
Page instfiles
; Sections ---------------------------------
Section -pre
ReadRegStr $0 HKCR "NSIS.Script\shell\compile" ""
ReadRegStr $1 HKCR "NSIS.Script\shell\ucompile" ""
${If} $0 == "Compile NSIS Script"
${OrIf} $0 == "Compile ANSI NSIS Script"
${OrIf} $0 == "Compile Unicode NSIS Script"
${OrIf} $1 == "Compile Unicode NSIS Script"
MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON1 "Remove existing context menu entries? (recommended)" IDNO +2
DeleteRegKey HKCR "NSIS.Script\shell\compile"
DeleteRegKey HKCR "NSIS.Script\shell\compile-compressor"
DeleteRegKey HKCR "NSIS.Script\shell\ucompile"
DeleteRegKey HKCR "NSIS.Script\shell\ucompile-compressor"
${EndIf}
Var /GLOBAL Counter
StrCpy $Counter 0
SectionEnd
Section "NSIS ANSI"
${If} ${FileExists} "$INSTDIR\ANSI\makensisw.exe"
Call createMenu
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "Icon" "$INSTDIR\ANSI\makensisw.exe,1"
;compile ansi
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\acompile" "MUIVerb" "Compile ANSI NSIS Script"
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\acompile\command" "" '"$INSTDIR\ANSI\makensisw.exe" "%1"'
;compile ansi (choose compressor)
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\acompile-compressor" "MUIVerb" "Compile ANSI NSIS Script (Choose Compressor)"
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\acompile-compressor\command" "" '"$INSTDIR\ANSI\makensisw.exe" /ChooseCompressor "%1"'
IntOp $Counter $Counter + 1
${EndIf}
SectionEnd
Section "Official NSIS"
${If} ${FileExists} "$INSTDIR\makensisw.exe"
${If} $Counter == 0
Call createMenu
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "Icon" "$INSTDIR\makensisw.exe,1"
${Else}
;add separator above the next entry
WriteRegDWORD HKCR "NSIS.Script\W7Menu\shell\compile" "CommandFlags" "32"
${EndIf}
;compile
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile" "MUIVerb" "Compile NSIS Script"
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile\command" "" '"$INSTDIR\makensisw.exe" "%1"'
;compile (choose compressor)
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile-compressor" "MUIVerb" "Compile NSIS Script (Choose Compressor)"
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\compile-compressor\command" "" '"$INSTDIR\makensisw.exe" /ChooseCompressor "%1"'
IntOp $Counter $Counter + 1
${EndIf}
SectionEnd
Section "NSIS Unicode"
${If} ${FileExists} "$INSTDIR\Unicode\makensisw.exe"
${If} $Counter == 0
Call createMenu
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "Icon" "$INSTDIR\Unicode\makensisw.exe,1"
${Else}
;add separator above the next entry
WriteRegDWORD HKCR "NSIS.Script\W7Menu\shell\ucompile" "CommandFlags" "32"
${EndIf}
;compile unicode
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile" "MUIVerb" "Compile Unicode NSIS Script"
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile\command" "" '"$INSTDIR\Unicode\makensisw.exe" "%1"'
;compile unicode (choose compressor)
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile-compressor" "MUIVerb" "Compile Unicode NSIS Script (Choose Compressor)"
WriteRegStr HKCR "NSIS.Script\W7Menu\shell\ucompile-compressor\command" "" '"$INSTDIR\Unicode\makensisw.exe" /ChooseCompressor "%1"'
IntOp $Counter $Counter + 1
${EndIf}
SectionEnd
Section -post
Quit
SectionEnd
; Functions --------------------------------
Function .onInit
SetRegView 32
FunctionEnd
Function createMenu
WriteRegStr HKCR ".nsi" "" "NSIS.Script"
;menu-name,submenu,icon
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "MUIVerb" "NSIS"
WriteRegStr HKCR "NSIS.Script\shell\NSIS.W7Menu" "ExtendedSubCommandsKey" "NSIS.Script\W7Menu"
FunctionEnd