帮我写一个nsis打包软件的脚本
时间: 2023-07-30 19:06:22 浏览: 122
nsis打包脚本
好的,下面是一个简单的 NSIS 脚本,用于打包一个名为 MySoftware 的软件:
```
; Script generated by the HM NIS Edit Script Wizard.
; Define the name and the output file of the installer
Name "MySoftware"
OutFile "MySoftwareInstaller.exe"
; Define the default installation directory
InstallDir "$PROGRAMFILES\MySoftware"
; Define the components to be installed
ComponentGroup "Main"
Component "MySoftware"
Component "Start Menu Shortcut"
; Define the files to be installed
Section "MySoftware" Section1
SetOutPath "$INSTDIR"
File "MySoftware.exe"
File "README.txt"
SectionEnd
; Define the Start Menu shortcut
Section "Start Menu Shortcut" Section2
CreateDirectory "$SMPROGRAMS\MySoftware"
CreateShortCut "$SMPROGRAMS\MySoftware\MySoftware.lnk" "$INSTDIR\MySoftware.exe" "" "" 0
SectionEnd
; Define the uninstaller
Section "Uninstall"
Delete "$INSTDIR\MySoftware.exe"
Delete "$INSTDIR\README.txt"
Delete "$SMPROGRAMS\MySoftware\MySoftware.lnk"
RMDir "$SMPROGRAMS\MySoftware"
RMDir "$INSTDIR"
SectionEnd
; Define the installer sections
SectionGroup /e "Install"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
SectionGroupEnd
SectionGroup /e "Uninstall"
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
SectionGroupEnd
; Define the installer attributes
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_UNICON "uninstall.ico"
!define MUI_ICON "installer.ico"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
```
这个脚本将 MySoftware.exe 和 README.txt 安装到 $PROGRAMFILES\MySoftware 目录下,并创建一个“开始菜单”快捷方式。当用户卸载软件时,脚本将删除这些文件和快捷方式。除此之外,脚本还定义了安装程序的界面和属性。请注意,这只是一个简单的示例脚本,您可以根据自己的需要进行修改和扩展。
阅读全文