Last active
December 16, 2024 11:17
-
-
Save CoolOppo/5fb681682281b6adf6d8e2a5446f06ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; The name of the installer | |
Name "YOURPROGRAM" | |
; To change from default installer icon: | |
;Icon "YOURPROGRAM.ico" | |
; The setup filename | |
OutFile "YOURPROGRAM_Setup.exe" | |
; The default installation directory | |
InstallDir $PROGRAMFILES\YOURPROGRAM | |
; Registry key to check for directory (so if you install again, it will | |
; overwrite the old one automatically) | |
InstallDirRegKey HKLM "Software\YOURPROGRAM" "Install_Dir" | |
RequestExecutionLevel admin | |
;-------------------------------- | |
; Pages | |
Page components | |
Page directory | |
Page instfiles | |
UninstPage uninstConfirm | |
UninstPage instfiles | |
;-------------------------------- | |
; The stuff to install | |
Section "YOURPROGRAM (required)" | |
SectionIn RO | |
; Set output path to the installation directory. | |
SetOutPath $INSTDIR | |
; Put file there (you can add more File lines too) | |
File "YOURPROGRAM.exe" | |
; Wildcards are allowed: | |
; File *.dll | |
; To add a folder named MYFOLDER and all files in it recursively, use this EXACT syntax: | |
; File /r MYFOLDER\*.* | |
; See: https://nsis.sourceforge.io/Reference/File | |
; MAKE SURE YOU PUT ALL THE FILES HERE IN THE UNINSTALLER TOO | |
; Write the installation path into the registry | |
WriteRegStr HKLM SOFTWARE\YOURPROGRAM "Install_Dir" "$INSTDIR" | |
; Write the uninstall keys for Windows | |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YOURPROGRAM" "DisplayName" "YOURPROGRAM" | |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YOURPROGRAM" "UninstallString" '"$INSTDIR\uninstall.exe"' | |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YOURPROGRAM" "NoModify" 1 | |
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YOURPROGRAM" "NoRepair" 1 | |
WriteUninstaller "$INSTDIR\uninstall.exe" | |
SectionEnd | |
; Optional section (can be disabled by the user) | |
Section "Start Menu Shortcuts (required)" | |
SectionIn RO | |
CreateDirectory "$SMPROGRAMS\YOURPROGRAM" | |
CreateShortcut "$SMPROGRAMS\YOURPROGRAM\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 | |
CreateShortcut "$SMPROGRAMS\YOURPROGRAM\YOURPROGRAM.lnk" "$INSTDIR\YOURPROGRAM.exe" "" "$INSTDIR\YOURPROGRAM.exe" 0 | |
SectionEnd | |
;-------------------------------- | |
; Uninstaller | |
Section "Uninstall" | |
; Remove registry keys | |
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YOURPROGRAM" | |
DeleteRegKey HKLM SOFTWARE\YOURPROGRAM | |
; Remove files and uninstaller | |
; MAKE SURE NOT TO USE A WILDCARD. IF A | |
; USER CHOOSES A STUPID INSTALL DIRECTORY, | |
; YOU'LL WIPE OUT OTHER FILES TOO | |
Delete $INSTDIR\YOURPROGRAM.exe | |
Delete $INSTDIR\uninstall.exe | |
; Remove shortcuts, if any | |
Delete "$SMPROGRAMS\YOURPROGRAM\*.*" | |
; Remove directories used (only deletes empty dirs) | |
RMDir "$SMPROGRAMS\YOURPROGRAM" | |
RMDir "$INSTDIR" | |
SectionEnd |
Hippity hoppity your code is now my property!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for your script !