window安装包制作工具NSIS (NullSoft Scriptable Install System)

1.制作脚本install.nsi

!include "MUI.nsh"

!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.

!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
!insertmacro MUI_PAGE_INSTFILES # Installing page.
!insertmacro MUI_PAGE_FINISH # Finished installation page.

!insertmacro MUI_LANGUAGE "SimpChinese"

Name "MyApp" # Name of the installer (usually the name of the application to install).
Icon "C:\installDic\Installer.ico" # 安装包的图标 128x128
OutFile "MyAppInstaller.exe" # Name of the installer's file.
InstallDir "$PROGRAMFILES\MyApp" # Default installing folder ($PROGRAMFILES is Program Files folder).
ShowInstDetails show # This will always show the installation details.
ShowUnInstDetails show

# In this section add your files or your folders.
# Add your files with "File (Name of the file)", example: "File "$DESKTOP\MyApp.exe"" ($DESKTOP is Desktop folder); or add your folders always with "File (Name of the folder)\*", always add your folders with an asterisk, example: "File /r $DESKTOP\MyApp\*" (this will add its files and (with /r its subfolders)).

Section "install"
  SetOutPath $INSTDIR
  #你的源码文件路径
  File "C:\installDic\*"
  writeUninstaller "$INSTDIR\uninstall.exe"
  
  #创建快捷方式
  #CreateDirectory "$SMPROGRAMS\MyApp\"
  #CreateShortcut "$SMPROGRAMS\MyApp\TXCloudPortal.lnk" $INSTDIR\TXCloudPortal.exe '"$INSTDIR\TXCloudPortal.image"' 
  #CreateShortcut "$DESKTOP\MSMK LIVE.lnk" $INSTDIR\TXCloudPortal.exe '"$INSTDIR\TXCloudPortal.image"' 
  #Exec '$INSTDIR\TXCloudPortal.exe "$INSTDIR\TXCloudPortal.image"'

   CreateShortCut "$DESKTOP\MSMK.lnk" "$INSTDIR\TXCloudPortal.exe"
SectionEnd

section "uninstall"
 
	# Remove Start Menu launcher
	delete "$SMPROGRAMS\MYAPP.lnk"
	# Try to remove the Start Menu folder - this will only happen if it is empty
	rmDir "$SMPROGRAMS\MYAPP"
 
	# Remove files
	delete $INSTDIR\*
 
	# Always delete uninstaller as the last action
	delete $INSTDIR\uninstall.exe
 
	# Try to remove the install directory - this will only happen if it is empty
	rmDir $INSTDIR
 
	# Remove uninstaller information from the registry
	# DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYAPP"
sectionEnd

2.打开nsis软件导入脚本

学习资料:

https://nsis.sourceforge.io/Category:Tutorials

https://en.wikipedia.org/wiki/Nullsoft_Scriptable_Install_System

猜你喜欢

转载自blog.csdn.net/oZhaiHenZhai/article/details/86646971