NSIS (Nullsoft Scriptable Install System) 是一个建立安装档非常好用且免费的软件。
有监於资讯的发展日新月异,在进入主题之前,我先注明一下本次笔记内所使用的软硬体概况:
使用前我试着翻阅中英文的说明,不得不说,这些说明反而让人望之却步,正当我苦恼之际,在软件的介面上,看到「Example scripts」几个字,顺势点进去之後,我分别开启 example1 与 example2 这 2 个档案,观察一下之後,就直接拿 example2 来改,原因是 example2 把 Uninstaller 的写法直接放进来,而这正是我需要的,服用的方式,也算容易,用 Notepad++ 打开後,我就用取代的方式,把关键字「Example2」换成我要安装的应用程序名称,除此之外,还走过下面几个步骤:
因为要打包的程序,在执行上的需求,我也就把 AccessControl plug-in 安装进来。
本以为,直接解压到 NSIS 的安装目录就可以,结果…,因为编译错误的关系,我发现要自己去把「i386-ansi」与「i386-unicode」里面的 AccessControl.dll 分别移到「x86-ansi」与「x86-unicode」(这支 AccessControl.dll 在两个夹子的名字都一样,因此,移动的时候,要特别注意别搞错)。
再经过几次调校後,就成功打包起来。
可以安装是一定要的。
然後,可以全权读取与写入,所以,程序的执行上,也没有什麽问题。
最後,跑一下 Uninstaller,确认可以移除档案、资料夹与捷径。
最後,考虑到安全性的问题,我就不提供 .nsi 的 Scripts 档下载,直接贴出来给大家参考,如果也刚好符合您大致上的需求,也可以直接复制去服用。
; DNW.nsi
;
; This script is based on example1.nsi, but it remember the directory,
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install DNW.nsi into a directory that the user selects.
;
; See install-shared.nsi for a more robust way of checking for administrator rights.
; See install-per-user.nsi for a file association example.
;--------------------------------
; The name of the installer
Name "DNW"
; The file to write
OutFile "DNWInstaller.exe"
; Request application privileges for Windows Vista and higher
RequestExecutionLevel admin
; Build Unicode installer
Unicode True
; The default installation directory
InstallDir $PROGRAMFILES\DNW
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\DNW" "Install_Dir"
;--------------------------------
; Pages
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "DNW (required)"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File "DNW.exe"
File "makeData.exe"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\DNW "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DNW" "DisplayName" "DNW"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DNW" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DNW" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DNW" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
Section
SetOutPath "$INSTDIR\data"
SetOverwrite on
File /nonfatal /r "$data\*.*"
AccessControl::GrantOnFile "$INSTDIR\data" "(S-1-1-0)" "FullAccess"
AccessControl::GrantOnFile "$INSTDIR\data" "(S-1-5-32-545)" "FullAccess"
# Give all authentificated users (BUILTIN\Users) full access on
# the registry key HKEY_LOCAL_MACHINE\Software\DNW
AccessControl::GrantOnRegKey \
HKLM "Software\DNW\data" "(BU)" "FullAccess"
Pop $0
SectionEnd
; Optional section
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\DNW"
CreateShortcut "$SMPROGRAMS\DNW\Uninstall.lnk" "$INSTDIR\uninstall.exe"
SetOutPath "$INSTDIR"
CreateShortcut "$SMPROGRAMS\DNW\DNW.lnk" "$INSTDIR\DNW.exe"
SectionEnd
; Optional section
Section "Desktop Shortcut"
SetOutPath "$INSTDIR"
CreateShortcut "$DESKTOP\DNW.lnk" "$INSTDIR\DNW.exe"
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DNW"
DeleteRegKey HKLM "SOFTWARE\DNW"
; Remove files and uninstaller
Delete "$INSTDIR\*.*"
Delete "$INSTDIR\data\*.*"
; Remove shortcuts, if any
Delete "$SMPROGRAMS\DNW\*.lnk"
Delete "$DESKTOP\DNW.lnk"
; Remove directories
RMDir "$INSTDIR\DNW\data"
RMDir "$INSTDIR\DNW"
RMDir "$INSTDIR"
RMDir /r "$INSTDIR"
SectionEnd
<<: 用我的 iMac 把 Clear Linux 安装到 USB 外接硬碟上
>>: VMware 5V0-31.20 转储 - 5V0-31.20 考试简介
一开始学习时用Sublime,久了之後也成为一种习惯(,,・ω・,,) 但是初学者很喜欢写一步骤就要...
ssh和smb可能会遇到人认证无效的问题,以下是其中最常见的解决方法 1.ssh 到系统C槽>...
堆叠跟柱列在程序中算是很基本的资料结构~ 它们的储存特性一个是LIFO~ 另一个则是FIFO~ 学习...
前言 JavaScript 内的物件都有内建的两个属性,可以实现对物件的存取,称为: getter ...
今天来阅读使用 Rails 的第一步!其实内文很多龙哥已经交过或提过! 此篇主要是介绍,写一写我遗失...