2017-01-27 15:55:38 +03:00
|
|
|
!include "MUI2.nsh"
|
|
|
|
!include "nsProcess.nsh"
|
|
|
|
|
2017-03-13 13:24:31 +03:00
|
|
|
!define MUI_ICON "../../resources/icons/yubioath.ico"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
;Start Menu Folder Page Configuration
|
2017-03-13 13:24:31 +03:00
|
|
|
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Yubico\Yubico Authenticator"
|
2017-01-27 15:55:38 +03:00
|
|
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
|
2017-03-13 13:24:31 +03:00
|
|
|
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Yubico\Yubico Authenticator"
|
2017-01-27 15:55:38 +03:00
|
|
|
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
|
|
|
!define MUI_ABORTWARNING
|
|
|
|
|
2017-03-24 16:16:06 +03:00
|
|
|
;Checkbox on finish page, "Run Yubico Authenticator"
|
2017-03-13 13:24:31 +03:00
|
|
|
!define MUI_FINISHPAGE_RUN "$INSTDIR\yubioath-desktop.exe"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
2017-08-17 16:51:44 +03:00
|
|
|
;Support High DPI displays.
|
|
|
|
ManifestDPIAware true
|
|
|
|
|
2017-01-27 15:55:38 +03:00
|
|
|
Var STARTMENU_FOLDER
|
|
|
|
|
|
|
|
!ifdef INNER
|
|
|
|
!echo "Inner invocation"
|
|
|
|
OutFile "$%TEMP%\tempinstaller.exe"
|
|
|
|
SetCompress off
|
|
|
|
!else
|
|
|
|
!echo "Outer invocation"
|
|
|
|
|
|
|
|
; Call makensis again, defining INNER. This writes an installer for us which, when
|
|
|
|
; it is invoked, will just write the uninstaller to some location, and then exit.
|
|
|
|
!system "$\"${NSISDIR}\makensis$\" /DINNER win-installer.nsi" = 0
|
|
|
|
|
|
|
|
; Run temp installer. Since it calls quit the return value isn't zero.
|
|
|
|
!system "$%TEMP%\tempinstaller.exe" = 2
|
|
|
|
|
|
|
|
; Sign real uninstaller.
|
2017-03-13 14:14:38 +03:00
|
|
|
!system "signtool.exe sign /fd SHA256 /t http://timestamp.verisign.com/scripts/timstamp.dll $%TEMP%\yubioath-desktop-uninstall.exe" = 0
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; The name of the installer
|
2017-03-13 13:24:31 +03:00
|
|
|
Name "Yubico Authenticator"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; The file to write
|
2019-06-24 15:00:41 +03:00
|
|
|
OutFile "../../yubioath-desktop-${VERSION}-win32.exe"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; The default installation directory
|
2017-03-13 13:24:31 +03:00
|
|
|
InstallDir "$PROGRAMFILES\Yubico\Yubico Authenticator"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; Registry key to check for directory (so if you install again, it will
|
|
|
|
; overwrite the old one automatically)
|
2017-03-13 13:24:31 +03:00
|
|
|
InstallDirRegKey HKLM "Software\Yubico\yubioath-desktop" "Install_Dir"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
SetCompressor /SOLID lzma
|
|
|
|
|
|
|
|
ShowInstDetails show
|
|
|
|
|
|
|
|
;Interface Settings
|
|
|
|
|
|
|
|
; Pages
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
|
|
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
|
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
|
|
!insertmacro MUI_PAGE_FINISH
|
|
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
|
|
|
|
|
|
;Languages
|
|
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
|
|
|
|
Section "Start Menu"
|
|
|
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
|
|
|
;Create shortcuts
|
|
|
|
SetShellVarContext all
|
|
|
|
SetOutPath "$SMPROGRAMS\$STARTMENU_FOLDER"
|
|
|
|
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
|
2017-03-13 13:24:31 +03:00
|
|
|
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Yubico Authenticator.lnk" "$INSTDIR\yubioath-desktop.exe"
|
|
|
|
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall Yubico Authenticator.lnk" "$INSTDIR\yubioath-desktop-uninstall.exe"
|
2017-01-27 15:55:38 +03:00
|
|
|
!insertmacro MUI_STARTMENU_WRITE_END
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
Section "Kill process" KillProcess
|
2017-03-13 13:24:31 +03:00
|
|
|
${nsProcess::FindProcess} "yubioath-desktop.exe" $R0
|
2017-01-27 15:55:38 +03:00
|
|
|
${If} $R0 == 0
|
2017-03-13 13:24:31 +03:00
|
|
|
DetailPrint "Yubico Authenticator is running. Closing..."
|
|
|
|
${nsProcess::CloseProcess} "yubioath-desktop.exe" $R0
|
2017-01-27 15:55:38 +03:00
|
|
|
Sleep 2000
|
|
|
|
${EndIf}
|
|
|
|
${nsProcess::Unload}
|
|
|
|
SectionEnd
|
|
|
|
!endif
|
|
|
|
|
|
|
|
Function .onInit
|
|
|
|
!ifdef INNER
|
2017-03-13 13:24:31 +03:00
|
|
|
WriteUninstaller "$%TEMP%\yubioath-desktop-uninstall.exe"
|
2017-01-27 15:55:38 +03:00
|
|
|
Quit
|
|
|
|
!endif
|
|
|
|
FunctionEnd
|
|
|
|
|
|
|
|
Var MYTMP
|
2017-03-13 13:24:31 +03:00
|
|
|
Section "Yubico Authenticator"
|
2017-01-27 15:55:38 +03:00
|
|
|
SectionIn RO
|
2017-03-13 14:16:45 +03:00
|
|
|
|
|
|
|
; Delete any old installation
|
|
|
|
RMDir /r $INSTDIR
|
|
|
|
|
2017-01-27 15:55:38 +03:00
|
|
|
SetOutPath $INSTDIR
|
2017-03-13 13:24:31 +03:00
|
|
|
FILE /r "..\..\release\*"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; Write the installation path into the registry
|
2017-03-13 13:24:31 +03:00
|
|
|
WriteRegStr HKLM "Software\Yubico\yubioath-desktop" "Install_Dir" "$INSTDIR"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; Windows Add/Remove Programs support
|
2017-03-13 13:24:31 +03:00
|
|
|
StrCpy $MYTMP "Software\Microsoft\Windows\CurrentVersion\Uninstall\yubioath-desktop"
|
2017-03-24 16:16:06 +03:00
|
|
|
WriteRegStr HKLM $MYTMP "DisplayName" "Yubico Authenticator"
|
2017-03-13 13:24:31 +03:00
|
|
|
WriteRegExpandStr HKLM $MYTMP "UninstallString" '"$INSTDIR\yubioath-desktop-uninstall.exe"'
|
2017-01-27 15:55:38 +03:00
|
|
|
WriteRegExpandStr HKLM $MYTMP "InstallLocation" "$INSTDIR"
|
|
|
|
WriteRegStr HKLM $MYTMP "DisplayVersion" "${VERSION}"
|
|
|
|
WriteRegStr HKLM $MYTMP "Publisher" "Yubico AB"
|
|
|
|
WriteRegStr HKLM $MYTMP "URLInfoAbout" "https://www.yubico.com"
|
|
|
|
WriteRegDWORD HKLM $MYTMP "NoModify" "1"
|
|
|
|
WriteRegDWORD HKLM $MYTMP "NoRepair" "1"
|
2017-03-24 14:42:25 +03:00
|
|
|
|
2018-11-08 01:24:14 +03:00
|
|
|
; Install Visual C++ Redistributable Packages
|
2017-03-24 16:06:17 +03:00
|
|
|
; will do nothing if already installed
|
2019-06-24 15:00:41 +03:00
|
|
|
ExecWait "$INSTDIR\vc_redist.x86.exe /q /norestart"
|
2017-03-24 16:06:17 +03:00
|
|
|
; Delete redist packages
|
2019-06-24 15:00:41 +03:00
|
|
|
Delete "$INSTDIR\vc_redist.x86.exe"
|
2017-03-24 14:42:25 +03:00
|
|
|
|
2017-01-27 15:55:38 +03:00
|
|
|
SectionEnd
|
2017-03-24 14:42:25 +03:00
|
|
|
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
Section
|
|
|
|
!ifndef INNER
|
|
|
|
SetOutPath $INSTDIR
|
2017-03-13 13:24:31 +03:00
|
|
|
File $%TEMP%\yubioath-desktop-uninstall.exe
|
2017-01-27 15:55:38 +03:00
|
|
|
!endif
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
!ifdef INNER
|
|
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
|
|
!endif
|
|
|
|
|
|
|
|
!ifdef INNER
|
|
|
|
Var MUI_TEMP
|
|
|
|
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
2017-03-13 13:24:31 +03:00
|
|
|
Name "Yubico Authenticator"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
Section "Uninstall"
|
|
|
|
; Remove registry keys
|
2017-03-13 13:24:31 +03:00
|
|
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\yubioath-desktop"
|
|
|
|
DeleteRegKey HKLM "Software\Yubico\yubioath-desktop"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
|
|
|
; Kill processes
|
2017-03-13 13:24:31 +03:00
|
|
|
${nsProcess::FindProcess} "yubioath-desktop.exe" $R0
|
2017-01-27 15:55:38 +03:00
|
|
|
${If} $R0 == 0
|
2017-03-13 13:24:31 +03:00
|
|
|
DetailPrint "Yubico Authenticator is running. Closing..."
|
|
|
|
${nsProcess::CloseProcess} "yubioath-desktop.exe" $R0
|
2017-01-27 15:55:38 +03:00
|
|
|
Sleep 2000
|
|
|
|
${EndIf}
|
|
|
|
${nsProcess::Unload}
|
|
|
|
|
|
|
|
; Remove the installation directory recursively
|
|
|
|
; NOTE! This behaviour assumes installation directory is hardcoded.
|
|
|
|
RMDir /r "$INSTDIR"
|
|
|
|
|
|
|
|
; Remove shortcuts, if any
|
|
|
|
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
|
|
|
|
SetShellVarContext all
|
2017-03-13 13:24:31 +03:00
|
|
|
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall Yubico Authenticator.lnk"
|
|
|
|
Delete "$SMPROGRAMS\$MUI_TEMP\Yubico Authenticator.lnk"
|
2017-01-27 15:55:38 +03:00
|
|
|
|
2018-11-08 01:10:57 +03:00
|
|
|
;Delete empty start menu parent directories
|
2017-01-27 15:55:38 +03:00
|
|
|
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
|
|
|
|
|
|
|
|
startMenuDeleteLoop:
|
|
|
|
ClearErrors
|
|
|
|
RMDir $MUI_TEMP
|
|
|
|
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
|
|
|
|
IfErrors startMenuDeleteLoopDone
|
|
|
|
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
|
|
|
|
startMenuDeleteLoopDone:
|
|
|
|
|
2017-03-13 13:24:31 +03:00
|
|
|
DeleteRegKey /ifempty HKCU "Software\Yubico\yubioath-desktop"
|
2017-01-27 15:55:38 +03:00
|
|
|
SectionEnd
|
|
|
|
!endif
|