forked from sailcut/sailcut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sailcut.nsi.in
102 lines (82 loc) · 3.04 KB
/
sailcut.nsi.in
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
!define PRODUCT_NAME "Sailcut CAD"
!define PRODUCT_DIR_REGKEY "Software\${PRODUCT_NAME}"
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${PRODUCT_OUTPUT}"
SetCompressor lzma
InstallDir "$PROGRAMFILES\${PRODUCT_NAME}"
InstallDirRegKey HKCU "${PRODUCT_DIR_REGKEY}" ""
!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\bin\sailcut.exe"
!define MUI_FINISHPAGE_LINK "Visit the Sailcut CAD website"
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.sailcut.com/"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
RequestExecutionLevel admin
Function ConditionalAddToRegisty
Pop $0
Pop $1
StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sailcut CAD" \
"$1" "$0"
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
DetailPrint "Set install registry entry: '$1' to '$0'"
ConditionalAddToRegisty_EmptyString:
FunctionEnd
Section "Sailcut CAD" SecSailcut
SectionIn RO
SetOutPath "$INSTDIR"
WriteRegStr HKCU "${PRODUCT_DIR_REGKEY}" "" $INSTDIR
File /r bin
File /r share
WriteUninstaller "$INSTDIR\uninstall.exe"
Push "DisplayIcon"
Push "$INSTDIR\bin\sailcut.exe"
Call ConditionalAddToRegisty
Push "DisplayName"
Push "${PRODUCT_NAME}"
Call ConditionalAddToRegisty
Push "DisplayVersion"
Push "${PRODUCT_VERSION}"
Call ConditionalAddToRegisty
Push "UninstallString"
Push "$INSTDIR\uninstall.exe"
Call ConditionalAddToRegisty
Push "NoRepair"
Push "1"
Call ConditionalAddToRegisty
SectionEnd
Section "Start Menu Shortcuts" SecShortcut
;Remove old shortcut folder
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}.lnk" "$INSTDIR\bin\sailcut.exe"
SectionEnd
Section "Register File Types" SecFileType
WriteRegStr HKCR "SailcutCAD.SailDef" "" "Sailcut CAD Sail definition"
WriteRegStr HKCR "SailcutCAD.SailDef\shell\open\command" "" '"$INSTDIR\sailcut.exe" "%1"'
WriteRegStr HKCR "SailcutCAD.SailDef\DefaultIcon" "" "$INSTDIR\icons\sailcut-file.ico"
WriteRegStr HKCR ".saildef" "" "SailcutCAD.SailDef"
SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecSailcut} "Installs Sailcut CAD."
!insertmacro MUI_DESCRIPTION_TEXT ${SecShortcut} "Adds icons to your start menu for easy access."
!insertmacro MUI_DESCRIPTION_TEXT ${SecFileType} "Register Sailcut CAD file types."
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Section "Uninstall"
DeleteRegKey HKCR "SailcutCAD.SailDef"
DeleteRegKey HKCR ".saildef"
DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
;Remove shortcuts
Delete "$SMPROGRAMS\${PRODUCT_NAME}.lnk"
;Remove the uninstaller itself.
Delete "$INSTDIR\uninstall.exe"
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sailcut CAD"
;Remove files
RMDir /r "$INSTDIR"
SectionEnd