-
Notifications
You must be signed in to change notification settings - Fork 7
/
installer.nsi
140 lines (108 loc) · 4.07 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# NSIS Installer Script for Reggie!
#
# Change the values below to change basic settings:
!define Name "Reggie! Level Editor Next"
!define InputDir "distrib\reggie_next_m2a4_win32"
!define OutputName "reggie-next-0.14-win32.exe"
!define Publisher "RVLution"
!define IconPath "reggiedata\win_icon.ico"
!define VersionStr "Milestone 2 Alpha 4"
###############################################################
###############################################################
###############################################################
###############################################################
# General
Name "${Name}"
OutFile "${OutputName}"
RequestExecutionLevel admin
InstallDir "$PROGRAMFILES\${Name}"
!include LogicLib.nsh
!include MUI2.nsh
!include "FileFunc.nsh"
!insertmacro GetTime
!define MUI_ICON "${IconPath}"
###############################################################
# Ask for admin privileges
Function .onInit
SetShellVarContext all
UserInfo::GetAccountType
pop $0
${If} $0 != "admin"
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 # ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
###############################################################
# Pages
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_RUN_FUNCTION CreateDesktopShortcut
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Start Menu shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateStartMenuShortcut
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
###############################################################
# Functions
Function CreateDesktopShortcut
CreateShortCut "$DESKTOP\${Name}.lnk" "$INSTDIR\reggie.exe"
FunctionEnd
Function CreateStartMenuShortcut
CreateShortCut "$SMPROGRAMS\${Name}.lnk" "$INSTDIR\reggie.exe"
FunctionEnd
###############################################################
# Sections
Section
# This fixes a bug, maybe
SetShellVarContext all
# Define output path
SetOutPath $INSTDIR
# Copy all files, recursively
File /r "${InputDir}\*.*"
# Create uninstaller
WriteUninstaller $INSTDIR\uninstall.exe
# Write registry keys so the uninstaller will
# show up in Control Panel
${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"DisplayIcon" "$INSTDIR\${IconPath}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"DisplayName" "${Name}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"DisplayVersion" "${VersionStr}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"InstallDate" "$2$1$0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"InstallLocation" "$INSTDIR\"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"Publisher" "${Publisher}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"URLInfoAbout" "http://rvlution.net"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}" \
"EstimatedSize" "$0"
SectionEnd
Section "Uninstall"
# This fixes a bug, maybe
SetShellVarContext all
# Delete uninstaller first
Delete $INSTDIR\uninstall.exe
# Delete the registry key folder, thereby deleting
# all the values contained within
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Name}"
# Delete shortcuts, if possible
Delete "$DESKTOP\${Name}.lnk"
Delete "$SMPROGRAMS\${Name}.lnk"
# Delete the entire folder recursively
RMDir /r $INSTDIR
SectionEnd