cotton_double/installer.nsi
2025-01-01 17:55:35 +08:00

89 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

; =========================
; NSIS Installer Script
; =========================
Unicode true
; 安装包名称
Name "cotton_double Installer"
; 生成的安装包文件名
OutFile "cotton_double_installer.exe"
; 图标(安装包 .exe 的图标),以及卸载图标
Icon "dist\nc.ico"
UninstallIcon "dist\nc.ico"
; 请求管理员权限(以便写入 HKLM 注册表,实现所有用户开机自启)
RequestExecutionLevel admin
; 默认安装路径
InstallDir "$PROGRAMFILES\cotton_double"
; --------------------------------
; 安装向导页面
; --------------------------------
; 1) 指定许可证文件 (纯文本或 RTF 都可)
LicenseData "dist\license.txt"
; 2) 内置页面依次为:
Page license ; 许可协议
Page directory ; 选择安装目录
Page instfiles ; 安装进度
; (去除 Page Finish基础 NSIS 无此内置页面,如需则使用 MUI 宏)
; --------------------------------
; Section: Main Installation
; --------------------------------
Section "MainSection"
; 将安装路径设为 $INSTDIR由用户在 Directory 页选择或使用默认)
SetOutPath "$INSTDIR"
; 将 dist 文件夹下的所有文件递归复制到 $INSTDIR
File /r "dist\*.*"
; ========== 创建快捷方式 ==========
; 1) 创建开始菜单文件夹 "cotton_double"
CreateDirectory "$SMPROGRAMS\cotton_double"
; 2) 在开始菜单中创建快捷方式
CreateShortcut "$SMPROGRAMS\cotton_double\cotton_double.lnk" \
"$INSTDIR\cotton_double2.exe" "" "$INSTDIR\nc.ico"
; 3) 在桌面创建快捷方式
CreateShortcut "$DESKTOP\cotton_double.lnk" \
"$INSTDIR\cotton_double2.exe" "" "$INSTDIR\nc.ico"
; ========== 设置开机自启(写注册表) ==========
; 如需只对当前用户生效,可改写为 HKCU
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" \
"cotton_double" "$INSTDIR\cotton_double2.exe"
; -- 关键:写出卸载程序 --
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
; --------------------------------
; Section: Uninstall
; --------------------------------
Section "Uninstall"
; 卸载时删除安装目录中的所有文件
RMDir /r "$INSTDIR"
; 删除桌面快捷方式
Delete "$DESKTOP\cotton_double2.lnk"
; 删除菜单快捷方式
Delete "$SMPROGRAMS\cotton_double\cotton_double2.lnk"
RMDir "$SMPROGRAMS\cotton_double"
; 移除注册表中的开机自启项
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "cotton_double"
; 可选:删除自身(卸载程序),一般放在最后
Delete "$INSTDIR\Uninstall.exe"
SectionEnd