!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" !define INST_KEY_BASE "Software\LoopAware\" !define INST_KEY_LAUNCHER "Screensavers\LauncherSettings" # Define name info !define PRODUCT_NAME "LoopAware Spooky Game" !define PRODUCT_VERSION "1.0.0.15" !define OutputFileName "LoopAware Spooky Game Installer v${PRODUCT_VERSION}.exe" Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" # Sign Executable macro ######################################## ######## Signing !define SIGNTOOL_EXECUTABLE "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\signtool.exe" !define /file OutFileSignPassword ".\config\passwd.txt" !define OutFileSignCertificate ".\config\certificate.p12" !macro sign_exe EXECUTABLE # CodeSigning with SHA1/AuthentiCode !execute 'PING -n 5 127.0.0.1 >NUL' # Delay Next Step to ensure File isn't locked by previous Process !execute '${SIGNTOOL_EXECUTABLE} sign /f ${OutFileSignCertificate} /p ${OutFileSignPassword} /fd sha1 /t http://timestamp.comodoca.com /v $\"${EXECUTABLE}$\"' # CodeSigning with SHA256/RFC 3161 !execute 'PING -n 5 127.0.0.1 >NUL' # Delay Next Step to ensure File isn't locked by previous Process !execute '${SIGNTOOL_EXECUTABLE} sign /f ${OutFileSignCertificate} /p ${OutFileSignPassword} /fd sha256 /tr http://timestamp.comodoca.com?td=sha256 /td sha256 /as /v $\"${EXECUTABLE}$\"' !macroend !macro sign_setup EXECUTABLE # CodeSigning with SHA1/AuthentiCode !finalize 'PING -n 5 127.0.0.1 >NUL' # Delay Next Step to ensure File isn't locked by previous Process !finalize '$\"${SIGNTOOL_EXECUTABLE}$\" sign /f $\"${OutFileSignCertificate}$\" /p ${OutFileSignPassword} /fd sha1 /t http://timestamp.comodoca.com /v $\"${EXECUTABLE}$\"' # CodeSigning with SHA256/RFC 3161 !finalize 'PING -n 5 127.0.0.1 >NUL' # Delay Next Step to ensure File isn't locked by previous Process !finalize '$\"${SIGNTOOL_EXECUTABLE}$\" sign /f $\"${OutFileSignCertificate}$\" /p ${OutFileSignPassword} /fd sha256 /tr http://timestamp.comodoca.com?td=sha256 /td sha256 /as /v $\"${EXECUTABLE}$\"' !macroend !ifdef INNER # https://nsis.sourceforge.io/Signing_an_Uninstaller !echo "Inner invocation" ; just to see what's going on OutFile "$%TEMP%\tempinstaller.exe" ; not really important where this is SetCompress off ; for speed !else !echo "Outer invocation" ; Call makensis again against current file, defining INNER. This writes an installer for us which, when ; it is invoked, will just write the uninstaller to some location, and then exit. !makensis '/DINNER "${__FILE__}"' = 0 ; So now run that installer we just created as %TEMP%\tempinstaller.exe. Since it ; calls quit the return value isn't zero. !system "$%TEMP%\tempinstaller.exe" = 2 ; That will have written an uninstaller binary for us. Now we sign it with your ; favorite code signing tool. !insertmacro sign_exe "$%TEMP%\loopaware spooky game uninstaller.exe" ; Good. Now we can carry on writing the real installer. OutFile "${OutputFileName}" SetCompressor /SOLID lzma !endif # set install directory InstallDir "$PROGRAMFILES64\loopaware\" # For removing Start Menu shortcut in Windows 7 !ifndef INNER RequestExecutionLevel admin !else RequestExecutionLevel admin !endif # Pages Page directory Page instfiles UninstPage uninstConfirm UninstPage instfiles ShowInstDetails show CRCCheck on Function .onInit !ifdef INNER ; If INNER is defined, then we aren't supposed to do anything except write out ; the uninstaller. This is better than processing a command line option as it means ; this entire code path is not present in the final (real) installer. SetSilent silent #RequestExecutionLevel user ; don't write uninstaller with admin permissions and prevent invoking UAC WriteUninstaller "$%TEMP%\loopaware spooky game uninstaller.exe" Quit ; just bail out quickly when running the "inner" installer !endif ; ...[the rest of your normal .onInit]... FunctionEnd # default section start Section # Sign executables !insertmacro sign_exe "./loopaware\spooky game\spooky game.exe" !insertmacro sign_exe "./loopaware\spooky game\libecos.dll" # define output path SetOutPath $INSTDIR CreateDirectory $INSTDIR # specify file to go in output path File /r loopaware\*.* # Write the uninstaller !ifndef INNER SetOutPath $INSTDIR ; this packages the signed uninstaller File "$%TEMP%\loopaware spooky game uninstaller.exe" !endif # Set 64-bit registry SetRegView 64 # Add Add/remove info WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" "DisplayName" "LoopAware - Spooky Game" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" "Publisher" "LoopAware" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" "Comments" "LoopAware is part of FJDATA AB." WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" "UninstallString" "$\"$INSTDIR\loopaware_spooky_game_uninstaller.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" "QuietUninstallString" "$\"$INSTDIR\loopaware_spooky_game_uninstaller.exe$\" /S" # Create shortcut to manager and launcher CreateDirectory "$SMPROGRAMS\LoopAware\Spooky Game" CreateShortCut "$SMPROGRAMS\LoopAware\Spooky Game\Remove LoopAware Spooky Game.lnk" "$INSTDIR\loopaware spooky game uninstaller.exe" CreateShortCut "$SMPROGRAMS\LoopAware\Spooky Game\Spooky Game.lnk" "$INSTDIR\spooky game\spooky game.exe" /c # Launch manager #Exec '"$INSTDIR\manager\LoopAware_Manager.exe" /c' ExecShell "open" "https://loopaware.com/spooky-game/new_install" #------- # default section end SectionEnd # create a section to define what the uninstaller does. # the section will always be named "Uninstall" !ifdef INNER Section "Uninstall" # Always delete uninstaller first Delete "$INSTDIR\loopaware_spooky_game_uninstaller.exe" # now delete installed file Delete $INSTDIR\*.* RMDir /r $INSTDIR # second, remove the links from the start menu Delete "$SMPROGRAMS\LoopAware\Spooky Game\Spooky Game.lnk" Delete "$SMPROGRAMS\LoopAware\Spooky Game\Remove LoopAware Spooky Game.lnk" RMDir /r "$SMPROGRAMS\LoopAware\Spooky Game" # Set 64-bit registry SetRegView 64 # Delete Add/remove info DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LoopAware_Spooky_Game" # Delete loopaware info DeleteRegKey /ifempty HKLM "Software\LoopAware" SectionEnd !endif # Sign the installer !insertmacro sign_setup "${OutputFileName}"