-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathinstaller.nsi
More file actions
137 lines (109 loc) · 4.82 KB
/
installer.nsi
File metadata and controls
137 lines (109 loc) · 4.82 KB
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
# FreePDF Install Script
# Using NSIS (Nullsoft Scriptable Install System)
# Include Modern UI
!include "MUI2.nsh"
!include "FileFunc.nsh"
# Program Information
Name "FreePDF"
OutFile "FreePDF_v5.1.2.exe"
InstallDir "$PROGRAMFILES64\FreePDF"
InstallDirRegKey HKLM "Software\FreePDF" "InstallPath"
RequestExecutionLevel admin
# Version Information
VIProductVersion "5.1.2.0"
VIAddVersionKey "ProductName" "FreePDF"
VIAddVersionKey "Comments" "Free PDF Translation Tool"
VIAddVersionKey "CompanyName" "FreePDF Team"
VIAddVersionKey "FileDescription" "FreePDF Setup"
VIAddVersionKey "FileVersion" "5.1.2.0"
VIAddVersionKey "ProductVersion" "5.1.2.0"
VIAddVersionKey "InternalName" "FreePDF"
VIAddVersionKey "LegalCopyright" "© 2025 FreePDF Team"
VIAddVersionKey "OriginalFilename" "FreePDF_Setup.exe"
# UI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "ui\logo\logo.ico"
!define MUI_UNICON "ui\logo\logo.ico"
# Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\FreePDF.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Launch FreePDF"
!insertmacro MUI_PAGE_FINISH
# Uninstall Pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
# Language
!insertmacro MUI_LANGUAGE "SimpChinese"
# Install Section - Only Main Program
Section "FreePDF" SecMain
SectionIn RO
# Set output path
SetOutPath "$INSTDIR"
# Copy program files
File /r "dist\FreePDF\*.*"
# Create start menu items
CreateDirectory "$SMPROGRAMS\FreePDF"
CreateShortCut "$SMPROGRAMS\FreePDF\FreePDF.lnk" "$INSTDIR\FreePDF.exe" "" "$INSTDIR\FreePDF.exe" 0
CreateShortCut "$SMPROGRAMS\FreePDF\Uninstall FreePDF.lnk" "$INSTDIR\Uninstall.exe"
# Create desktop shortcut
CreateShortCut "$DESKTOP\FreePDF.lnk" "$INSTDIR\FreePDF.exe" "" "$INSTDIR\FreePDF.exe" 0
# Registry entries
WriteRegStr HKLM "Software\FreePDF" "InstallPath" "$INSTDIR"
WriteRegStr HKLM "Software\FreePDF" "Version" "5.1.2"
# Add to control panel programs list
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "DisplayName" "FreePDF"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "DisplayIcon" "$INSTDIR\FreePDF.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "Publisher" "FreePDF Team"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "DisplayVersion" "5.1.2"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "NoRepair" 1
# Calculate install size
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "EstimatedSize" "$0"
# Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
# Uninstaller
Section "Uninstall"
# Delete files
RMDir /r "$INSTDIR"
# Delete start menu items
RMDir /r "$SMPROGRAMS\FreePDF"
# Delete desktop shortcut
Delete "$DESKTOP\FreePDF.lnk"
# Delete registry entries
DeleteRegKey HKLM "Software\FreePDF"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF"
SectionEnd
# Pre-install check with improved update logic
Function .onInit
# Check if already installed
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FreePDF" "UninstallString"
ReadRegStr $R1 HKLM "Software\FreePDF" "Version"
StrCmp $R0 "" done
# Check version for better update messaging
StrCmp $R1 "5.1.2" same_version different_version
same_version:
MessageBox MB_OKCANCEL|MB_ICONQUESTION "FreePDF v5.1.2 is already installed.$\n$\nClick OK to reinstall or Cancel to exit." IDOK uninst
Abort
different_version:
MessageBox MB_OKCANCEL|MB_ICONINFORMATION "FreePDF $R1 is installed.$\n$\nClick OK to upgrade to v5.1.2 or Cancel to exit." IDOK uninst
Abort
uninst:
ClearErrors
ExecWait '$R0 /S _?=$INSTDIR'
IfErrors no_remove_uninstaller done
IfFileExists "$INSTDIR\FreePDF.exe" no_remove_uninstaller done
Delete $R0
RMDir "$INSTDIR"
no_remove_uninstaller:
done:
FunctionEnd