2021-07-21 03:37:10 -04:00
/ * *
* Looking Glass
2022-01-05 19:42:46 +11:00
* Copyright © 2017- 2022 The Looking Glass Authors
2021-07-21 03:37:10 -04:00
* https : / /looking - glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111- 1307 USA
* /
2020-05-21 09:56:54 -05:00
2020-12-08 10:33:23 -05:00
;Include
2020-05-21 09:56:54 -05:00
!include " MUI2.nsh "
!include " FileFunc.nsh "
!include " LogicLib.nsh "
!include " Sections.nsh "
;Settings
2020-08-12 21:50:48 +10:00
Name " Looking Glass (host) "
2021-09-21 07:31:59 -04:00
OutFile " looking-glass-host-setup.exe "
2020-05-21 09:56:54 -05:00
Unicode true
RequestExecutionLevel admin
ShowInstDetails " show "
ShowUninstDetails " show "
2021-12-25 18:58:47 -05:00
ManifestDPIAware true
2020-05-21 09:56:54 -05:00
2021-09-21 07:31:59 -04:00
!ifndef BUILD_32BIT
Target AMD64- Unicode
2021-10-17 19:22:50 -04:00
InstallDir " $PROGRAMFILES \Looking Glass (host) "
!else
InstallDir " $PROGRAMFILES64 \Looking Glass (host) "
2021-09-21 07:31:59 -04:00
!endif
2020-08-12 21:50:48 +10:00
!define MUI_ICON " icon.ico "
!define MUI_UNICON " icon.ico "
2020-05-21 09:56:54 -05:00
!define MUI_LICENSEPAGE_BUTTON " Agree "
2020-12-08 12:37:40 -05:00
!define MUI_BGCOLOR " 3c046c "
!define MUI_TEXTCOLOR " ffffff "
!define MUI_WELCOMEFINISHPAGE_BITMAP " ${NSISDIR} \Contrib\Graphics\Wizard\nsis3-grey.bmp "
2020-10-09 02:36:48 +11:00
!define /file VERSION " ../../VERSION "
2020-05-21 09:56:54 -05:00
2020-12-08 13:36:18 -05:00
!define MUI_WELCOMEPAGE_TEXT " You are about to install $(^Name) version ${VERSION}.$\r$\n$\r$\nWhen upgrading, you don't need to close your Looking Glass client, but should install the ${VERSION} client after installation is complete.$\r$\n$\r$\nPress Next to continue. "
2020-12-08 10:33:23 -05:00
2020-05-21 09:56:54 -05:00
;Install and uninstall pages
2020-12-08 10:33:23 -05:00
!insertmacro MUI_PAGE_WELCOME
2020-08-12 21:50:48 +10:00
!insertmacro MUI_PAGE_LICENSE " LICENSE.txt "
2020-05-23 15:48:52 -05:00
!insertmacro MUI_PAGE_DIRECTORY
2020-05-21 09:56:54 -05:00
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE " English "
2020-05-23 15:48:52 -05:00
Function ShowHelpMessage
2020-08-12 21:50:48 +10:00
!define line1 " Command line options:$\r$\n$\r$\n "
!define line2 " /S - silent install (must be uppercase)$\r$\n "
!define line3 " /D=path\to\install\folder - Change install directory$\r$\n "
!define line4 " (Must be uppercase, the last option given and no quotes)$\r$\n$\r$\n "
!define line5 " /startmenu - create start menu shortcut$\r$\n "
!define line6 " /desktop - create desktop shortcut$\r$\n "
!define line7 " /noservice - do not create a service to auto start and elevate the host "
MessageBox MB_OK " ${line1}${line2}${line3}${line4}${line5}${line6}${line7} "
Abort
2020-05-23 15:48:52 -05:00
FunctionEnd
Function .onInit
2020-08-12 21:50:48 +10:00
var /GLOBAL cmdLineParams
Push $R0
${GetParameters} $cmdLine Params
ClearErrors
${GetOptions} $cmdLine Params '/?' $R0
IfErrors + 2 0
Call ShowHelpMessage
${GetOptions} $cmdLine Params '/H' $R0
IfErrors + 2 0
Call ShowHelpMessage
Pop $R0
Var /GLOBAL option_startMenu
Var /GLOBAL option_desktop
Var /GlOBAL option_noservice
StrCpy $option_startMenu 0
StrCpy $option_desktop 0
StrCpy $option_noservice 0
2021-12-25 02:58:48 -05:00
!ifdef IVSHMEM
Var /GlOBAL option_driver
StrCpy $option_driver 0
!endif
2020-08-12 21:50:48 +10:00
Push $R0
2021-12-25 03:07:09 -05:00
2020-08-12 21:50:48 +10:00
${GetOptions} $cmdLine Params '/startmenu' $R0
IfErrors + 2 0
StrCpy $option_startMenu 1
${GetOptions} $cmdLine Params '/desktop' $R0
IfErrors + 2 0
StrCpy $option_desktop 1
${GetOptions} $cmdLine Params '/noservice' $R0
IfErrors + 2 0
StrCpy $option_noservice 1
2021-12-25 02:58:48 -05:00
!ifdef IVSHMEM
${GetOptions} $cmdLine Params '/driver' $R0
IfErrors + 2 0
StrCpy $option_driver 1
!endif
2020-08-12 21:50:48 +10:00
Pop $R0
2020-05-23 15:48:52 -05:00
FunctionEnd
2020-12-08 16:15:00 -05:00
!macro StopLookingGlassService
;Attempt to stop existing LG service only if it exists
nsExec :: Exec 'sc.exe query "Looking Glass (host)"'
Pop $0 ; SC.exe error level
${If} $0 == 0 ; If error level is 0, service exists
2020-12-08 23:56:09 -05:00
DetailPrint " Stop service: Looking Glass (host) "
2020-12-08 16:15:00 -05:00
nsExec :: ExecToLog 'net.exe STOP "Looking Glass (host)"'
${EndIf}
!macroend
2020-05-21 09:56:54 -05:00
;Install
2021-12-25 02:58:48 -05:00
!ifdef IVSHMEM
Section " IVSHMEM Driver " Section0
StrCpy $option_driver 1
SectionEnd
Section " -IVSHMEM Driver "
${If} $option_driver == 1
DetailPrint " Extracting IVSHMEM driver "
SetOutPath $INSTDIR
File ..\ ..\ ivshmem\ ivshmem.cat
File ..\ ..\ ivshmem\ ivshmem.inf
File ..\ ..\ ivshmem\ ivshmem.sys
File /nonfatal ..\ ..\ ivshmem\ ivshmem.pdb
DetailPrint " Installing IVSHMEM driver "
nsExec :: ExecToLog '"$SYSDIR\pnputil.exe" /add-driver "$INSTDIR\ivshmem.inf" /install'
${EndIf}
SectionEnd
!endif
2020-05-23 15:48:52 -05:00
Section " -Install " Section1
2020-05-21 09:56:54 -05:00
2020-12-08 16:15:00 -05:00
!insertmacro StopLookingGlassService
2020-08-12 21:50:48 +10:00
2020-05-21 09:56:54 -05:00
SetOutPath $INSTDIR
2020-08-12 21:50:48 +10:00
File ..\ ..\ looking- glass- host.exe
2021-01-26 22:55:25 +11:00
File /nonfatal ..\ ..\ looking- glass- host.pdb
2020-08-12 21:50:48 +10:00
File LICENSE.txt
2020-05-21 09:56:54 -05:00
WriteUninstaller $INSTDIR \ uninstaller.exe
${GetSize} " $INSTDIR " " /S=0K " $0 $1 $2
IntFmt $0 " 0x%08X " $0
2020-08-12 21:50:48 +10:00
WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" EstimatedSize " " $0 "
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
2020-08-12 22:03:10 +10:00
" DisplayName " " Looking Glass (host) "
2020-08-12 21:50:48 +10:00
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" UninstallString " " $\" $INSTDIR \uninstaller.exe$\ " "
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" QuietUninstallString " " $\" $INSTDIR \uninstaller.exe$\ " /S "
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" InstallLocation " " $INSTDIR "
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" Publisher " " Geoffrey McRae "
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" DisplayIcon " " $\" $INSTDIR \looking-glass-host.exe$\ " "
WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" NoRepair " " 1 "
WriteRegDWORD HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
" NoModify " " 1 "
WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) " \
2020-10-09 02:51:28 +11:00
" DisplayVersion " ${VERSION}
2020-05-21 09:56:54 -05:00
SectionEnd
2020-08-12 21:50:48 +10:00
Section " Looking Glass (host) Service " Section2
2020-05-21 09:56:54 -05:00
2020-08-11 15:32:35 -05:00
${If} $option_noservice == 0
2020-12-08 16:15:00 -05:00
DetailPrint " Install service: Looking Glass (host) "
2020-08-11 15:32:35 -05:00
nsExec :: Exec '"$INSTDIR\looking-glass-host.exe" UninstallService'
2020-12-08 16:15:00 -05:00
nsExec :: ExecToLog '"$INSTDIR\looking-glass-host.exe" InstallService'
2020-08-11 15:32:35 -05:00
${EndIf}
2020-05-21 09:56:54 -05:00
SectionEnd
Section /o " Desktop Shortcut " Section3
2020-05-23 15:48:52 -05:00
StrCpy $option_desktop 1
2020-05-21 09:56:54 -05:00
SectionEnd
2021-01-28 21:03:26 -05:00
Section " Start Menu Shortcut " Section4
2020-05-23 15:48:52 -05:00
StrCpy $option_startMenu 1
2020-05-21 09:56:54 -05:00
SectionEnd
2020-05-23 15:48:52 -05:00
Section " -Hidden Start Menu " Section5
SetShellVarContext all
2021-12-25 03:07:09 -05:00
2020-05-23 15:48:52 -05:00
${If} $option_startMenu == 1
2021-01-28 21:03:26 -05:00
CreateDirectory " $APPDATA \Looking Glass (host) "
CreateDirectory " $SMPROGRAMS \Looking Glass (host) "
CreateShortCut " $SMPROGRAMS \Looking Glass (host)\Looking Glass (host).lnk " $INSTDIR \ looking- glass- host.exe
CreateShortCut " $SMPROGRAMS \Looking Glass (host)\Looking Glass Logs.lnk " " $APPDATA \Looking Glass (host) "
2020-05-23 15:48:52 -05:00
${EndIf}
${If} $option_desktop == 1
2020-08-12 21:50:48 +10:00
CreateShortCut " $DESKTOP \Looking Glass (host).lnk " $INSTDIR \ looking- glass- host.exe
2020-05-23 15:48:52 -05:00
${EndIf}
SectionEnd
2020-05-21 09:56:54 -05:00
2020-05-23 15:48:52 -05:00
Section " Uninstall " Section6
2020-05-21 09:56:54 -05:00
SetShellVarContext all
2020-12-08 16:15:00 -05:00
!insertmacro StopLookingGlassService
DetailPrint " Uninstall service: Looking Glass (host) "
nsExec :: ExecToLog '"$INSTDIR\looking-glass-host.exe" UninstallService'
2020-05-21 09:56:54 -05:00
2020-08-12 21:50:48 +10:00
DeleteRegKey HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking Glass (host) "
Delete " $SMPROGRAMS \Looking Glass (host).lnk "
Delete " $DESKTOP \Looking Glass (host).lnk "
Delete " $INSTDIR \uninstaller.exe "
Delete " $INSTDIR \looking-glass-host.exe "
2021-12-25 03:07:09 -05:00
Delete " $INSTDIR \looking-glass-host.pdb "
2021-12-25 02:58:48 -05:00
Delete " $INSTDIR \ivshmem.cat "
Delete " $INSTDIR \ivshmem.inf "
Delete " $INSTDIR \ivshmem.sys "
Delete " $INSTDIR \ivshmem.pdb "
2020-08-12 21:50:48 +10:00
Delete " $INSTDIR \LICENSE.txt "
2020-05-21 09:56:54 -05:00
RMDir $INSTDIR
SectionEnd
;Description text for selection of install items
2021-12-25 02:58:48 -05:00
LangString DESC_Section0 ${LANG_ENGLISH} " Install the IVSHMEM driver. This driver is needed for Looking Glass to function. This will replace the driver if it is already installed. "
2020-05-21 09:56:54 -05:00
LangString DESC_Section1 ${LANG_ENGLISH} " Install Files into $INSTDIR "
2020-08-12 21:50:48 +10:00
LangString DESC_Section2 ${LANG_ENGLISH} " Install service to automatically start Looking Glass (host). "
2020-05-21 09:56:54 -05:00
LangString DESC_Section3 ${LANG_ENGLISH} " Create desktop shortcut icon. "
LangString DESC_Section4 ${LANG_ENGLISH} " Create start menu shortcut. "
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
2021-12-25 02:58:48 -05:00
!ifdef IVSHMEM
!insertmacro MUI_DESCRIPTION_TEXT ${Section0} $ ( DESC_Section0)
!endif
2020-05-21 09:56:54 -05:00
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $ ( DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $ ( DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $ ( DESC_Section3)
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} $ ( DESC_Section4)
2020-05-23 15:48:52 -05:00
!insertmacro MUI_FUNCTION_DESCRIPTION_END