-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.nsi
99 lines (80 loc) · 3.77 KB
/
update.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
!include "MUI.nsh"
!define PRODUCT_NAME "PyMediaPlayer"
!define PRODUCT_VERSION "1.1.0"
!define PRODUCT_PUBLISHER "Gurraoptimus Development"
!define PRODUCT_URL "https://gurraoptimus.github.io/NSIS"
!define MUI_ICON "io.ico"
!define MUI_PAGE_HEADER_TEXT "PyMediaPlayer"
!define MUI_PAGE_HEADER_SUBTEXT "Open-source software licensed under the MIT License. ${PRODUCT_URL} "
!define MUI_HEADERIMAGE
!define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp"
!define VERSION "1875"
!define OLD_VERSION "1870"
Name "${PRODUCT_NAME}"
InstallDir "$PROGRAMFILES\pymp"
OutFile "PyMediaPlayer_${PRODUCT_VERSION}.exe"
BrandingText "{Gurraoptimus Development}"
RequestExecutionLevel admin
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
;!insertmacro MUI_LANGUAGE "Swedish"
;!insertmacro MUI_LANGUAGE "korean"
Section ""
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "DisplayVersion"
StrCmp $R0 "" InstallNew UpdateExisting
InstallNew:
MessageBox MB_OK "Installing PyMediaPlayer ${PRODUCT_VERSION}."
UpdateExisting:
MessageBox MB_YESNO "PyMediaPlayer $R0 is already installed. Update to ${PRODUCT_VERSION}?" IDNO EndInstall
; Installation steps
SetOutPath $INSTDIR
File "LICENSE.txt"
File "io.ico"
File "readme.md"
File "pymp.exe"
; Shortcuts
CreateShortcut "$DESKTOP\PyMediaPlayer.lnk" "$INSTDIR\pymp.exe" "" "$INSTDIR\io.ico" 0
CreateShortcut "$DESKTOP\Codec.lnk" "$INSTDIR\Codec_${VERSION}.exe"
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}\PyMediaPlayer.lnk" "$INSTDIR\pymp.exe" "" "$INSTDIR\io.ico" 0
CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}\Codec.lnk" "$INSTDIR\Codec_${VERSION}.exe"
; Install Codec Pack Silently
File "Codec_${OLD_VERSION}.exe"
Rename "$INSTDIR\Codec_${OLD_VERSION}.exe" "$INSTDIR\Codec_${VERSION}.exe"
ExecWait '"$INSTDIR\Codec_${VERSION}.exe" /verysilent /norestart'
WriteUninstaller "$INSTDIR\Uninstall.exe"
; Registry Updates
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "URLInfoAbout" "${PRODUCT_URL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "DisplayIcon" "$INSTDIR\io.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp" "UninstallString" "$INSTDIR\Uninstall.exe"
; Movies Directory
SetOutPath "$INSTDIR\Movies"
CreateDirectory "$INSTDIR\Movies"
File "Intro.mp4"
MessageBox MB_OK "${PRODUCT_NAME} has been installed/updated successfully!"
Goto EndInstall
EndInstall:
SectionEnd
Section "Uninstall"
MessageBox MB_YESNO "Are you sure you want to uninstall ${PRODUCT_NAME}?" IDNO AbortUninstall
; Remove directories
RMDir /r "$INSTDIR"
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
; Delete shortcuts
Delete "$DESKTOP\PyMediaPlayer.lnk"
Delete "$DESKTOP\Codec.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\PyMediaPlayer.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Codec.lnk"
; Registry cleanup
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\pymp"
MessageBox MB_OK "${PRODUCT_NAME} has been uninstalled."
AbortUninstall:
SectionEnd