This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Pass4Win.nsi
172 lines (137 loc) · 6.67 KB
/
Pass4Win.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#
# Pass4Win NSIS script
#
!define src_dir "."
!define APPNAME "Pass4Win"
!define DESCRIPTION "Windows version of Pass (http://www.passwordstore.org/) in the sense that the store (password structure) is and should be exactly the same between the two programs."
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
# It is possible to use "mailto:" links in here to open the email client
!define HELPURL "https://github.com/mbos/Pass4Win" # "Support Information" link
!define UPDATEURL "https://github.com/mbos/Pass4Win" # "Product Updates" link
!define ABOUTURL "https://github.com/mbos/Pass4Win" # "Publisher" link
# This is the size (in kB) of all the files copied into "Program Files"
!define INSTALLSIZE 8349
#SilentInstall silent
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
# This will be in the installer/uninstaller's title bar
Name "${APPNAME} version ${VERSION}"
Icon "Pass4Win/icon/lock.ico"
outFile "Pass4Win-Setup-v${VERSION}-${PLATFORM}.exe"
InstallDir "$PROGRAMFILES\${APPNAME}"
# Just three pages - license agreement, install location, and installation
page directory
Page instfiles
!macro VerifyUserIsAdmin
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
messageBox mb_iconstop "Administrator rights required!"
setErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
quit
${EndIf}
!macroend
Function .onInit
!include LogicLib.nsh
${If} ${PLATFORM} == "x64"
StrCpy $INSTDIR "$PROGRAMFILES64\${APPNAME}"
${EndIf}
setShellVarContext all
!insertmacro VerifyUserIsAdmin
!include WinMessages.nsh
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "Pass4Win") i .R0'
IntCmp $R0 0 notRunning
System::Call 'kernel32::CloseHandle(i $R0)'
MessageBox MB_OK|MB_ICONEXCLAMATION "Pass4Win is running. Please close it first" /SD IDOK
Abort
notRunning:
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
"UninstallString"
StrCmp $R0 "" done
ClearErrors
HideWindow
ClearErrors
ExecWait '$R0 _?=$INSTDIR /S'
BringToFront
IfErrors no_remove_uninstaller done
no_remove_uninstaller:
done:
FunctionEnd
section "install"
# Files for the install directory - to build the installer, these should be in the same directory as the install script (this file)
setOutPath $INSTDIR
# Files added here should be removed by the uninstaller (see section "uninstall")
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\Pass4Win.exe"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\Pass4Win.exe.config"
SetOutPath "$INSTDIR\NativeBinaries\x86"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\NativeBinaries\x86\git2-e0902fb.dll"
SetOutPath "$INSTDIR\NativeBinaries\amd64"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\NativeBinaries\amd64\git2-e0902fb.dll"
# Localezation
SetOutPath "$INSTDIR\nl"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\nl\Pass4Win.resources.dll"
SetOutPath "$INSTDIR\it"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\it\Pass4Win.resources.dll"
SetOutPath "$INSTDIR\de"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\de\Pass4Win.resources.dll"
SetOutPath "$INSTDIR\fr"
file "${src_dir}\Pass4Win\bin\${PLATFORM}\Release\fr\Pass4Win.resources.dll"
# Uninstaller - See function un.onInit and section "uninstall" for configuration
writeUninstaller "$INSTDIR\uninstall.exe"
# Start Menu
createDirectory "$SMPROGRAMS\${APPNAME}"
createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\Pass4Win.exe" "" "$INSTDIR\Pass4Win.exe"
# Desktop
CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\Pass4Win.exe" "" "$INSTDIR\Pass4Win.exe"
# Registry information for add/remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME} - ${DESCRIPTION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallLocation" "$\"$INSTDIR$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$\"$INSTDIR\Pass4Win.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "$\"Mike Bos$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "HelpLink" "$\"${HELPURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "URLUpdateInfo" "$\"${UPDATEURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "URLInfoAbout" "$\"${ABOUTURL}$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "$\"${VERSION}$\""
# There is no option for modifying or repairing the install
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "NoRepair" 1
# Set the INSTALLSIZE constant (!defined at the top of this script) so Add/Remove Programs can accurately report the size
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "EstimatedSize" ${INSTALLSIZE}
sectionEnd
# Uninstaller
function un.onInit
SetShellVarContext all
#Verify the uninstaller - last chance to back out
!insertmacro VerifyUserIsAdmin
functionEnd
section "uninstall"
# Remove Start Menu launcher
delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
# Try to remove the Start Menu folder - this will only happen if it is empty
rmDir "$SMPROGRAMS\${APPNAME}"
# Remove desktop shortcut
Delete "$DESKTOP\${APPNAME}.lnk"
# Remove files
delete $INSTDIR\Pass4Win.exe
delete $INSTDIR\NativeBinaries\x86\git2-e0902fb.dll
rmdir $INSTDIR\NativeBinaries\x86
Delete $INSTDIR\NativeBinaries\amd64\git2-e0902fb.dll
RMDir $INSTDIR\NativeBinaries\amd64
RMDir $INSTDIR\NativeBinaries
Delete $INSTDIR\nl\Pass4Win.resources.dll
RMDir $INSTDIR\nl
Delete $INSTDIR\it\Pass4Win.resources.dll
RMDir $INSTDIR\it
Delete $INSTDIR\de\Pass4Win.resources.dll
RMDir $INSTDIR\de
Delete $INSTDIR\fr\Pass4Win.resources.dll
RMDir $INSTDIR\fr
# Always delete uninstaller as the last action
delete $INSTDIR\uninstall.exe
# Try to remove the install directory - this will only happen if it is empty
rmDir $INSTDIR
# Remove uninstaller information from the registry
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
sectionEnd