[Host] Installer command line options and install location selection add

This commit is contained in:
TheCakeIsNaOH 2020-05-23 15:48:52 -05:00 committed by Geoffrey McRae
parent b2980fea63
commit e2f2437ef4

View File

@ -40,15 +40,64 @@ InstallDir "$PROGRAMFILES64\Looking-Glass"
;Install and uninstall pages ;Install and uninstall pages
!insertmacro MUI_PAGE_LICENSE "..\..\LICENSE" !insertmacro MUI_PAGE_LICENSE "..\..\LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
Function ShowHelpMessage
!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"
MessageBox MB_OK "${line1}${line2}${line3}${line4}${line5}${line6}"
Abort
FunctionEnd
Function .onInit
var /GLOBAL cmdLineParams
Push $R0
${GetParameters} $cmdLineParams
ClearErrors
${GetOptions} $cmdLineParams '/?' $R0
IfErrors +2 0
Call ShowHelpMessage
${GetOptions} $cmdLineParams '/H' $R0
IfErrors +2 0
Call ShowHelpMessage
Pop $R0
Var /GLOBAL option_startMenu
Var /GLOBAL option_desktop
StrCpy $option_startMenu 0
StrCpy $option_desktop 0
Push $R0
${GetOptions} $cmdLineParams '/startmenu' $R0
IfErrors +2 0
StrCpy $option_startMenu 1
${GetOptions} $cmdLineParams '/desktop' $R0
IfErrors +2 0
StrCpy $option_desktop 1
Pop $R0
FunctionEnd
;Install ;Install
Section "Install" Section1 Section "-Install" Section1
SectionIn RO
SetOutPath $INSTDIR SetOutPath $INSTDIR
File ..\build\looking-glass-host.exe File ..\build\looking-glass-host.exe
@ -83,32 +132,42 @@ SectionEnd
Section "Auto Start Looking-Glass" Section2 Section "Auto Start Looking-Glass" Section2
nsExec::Exec 'SCHTASKS /Delete /F /TN "Looking Glass"' nsExec::Exec 'SCHTASKS /Delete /F /TN "Looking Glass"'
nsExec::Exec 'SCHTASKS /Create /TN "Looking Glass" /SC ONLOGON /RL HIGHEST /TR "C:\Program Files\Looking-Glass\looking-glass-host.exe"' nsExec::Exec 'SCHTASKS /Create /TN "Looking Glass" /SC ONLOGON /RL HIGHEST /TR "$INSTDIR\looking-glass-host.exe"'
SectionEnd SectionEnd
Section /o "Desktop Shortcut" Section3 Section /o "Desktop Shortcut" Section3
SetShellVarContext all StrCpy $option_desktop 1
CreateShortCut $DESKTOP\Looking-Glass-Host.lnk $INSTDIR\looking-glass-host.exe
SectionEnd SectionEnd
Section /o "Start Menu Shortcut" Section4 Section /o "Start Menu Shortcut" Section4
SetShellVarContext all StrCpy $option_startMenu 1
CreateShortCut $STARTMENU\Looking-Glass-Host.lnk $INSTDIR\looking-glass-host.exe
SectionEnd SectionEnd
Section "-Hidden Start Menu" Section5
SetShellVarContext all
${If} $option_startMenu == 1
CreateShortCut $SMPROGRAMS\Looking-Glass-Host.lnk $INSTDIR\looking-glass-host.exe
${EndIf}
Section "Uninstall" Section5 ${If} $option_desktop == 1
CreateShortCut $DESKTOP\Looking-Glass-Host.lnk $INSTDIR\looking-glass-host.exe
${EndIf}
SectionEnd
Section "Uninstall" Section6
SetShellVarContext all SetShellVarContext all
nsExec::Exec 'SCHTASKS /Delete /F /TN "Looking Glass"' nsExec::Exec 'SCHTASKS /Delete /F /TN "Looking Glass"'
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Looking-Glass"
Delete $STARTMENU\Looking-Glass-Host.lnk Delete $SMPROGRAMS\Looking-Glass-Host.lnk
Delete $DESKTOP\Looking-Glass-Host.lnk Delete $DESKTOP\Looking-Glass-Host.lnk
Delete $INSTDIR\uninstaller.exe Delete $INSTDIR\uninstaller.exe
Delete $INSTDIR\looking-glass-host.exe Delete $INSTDIR\looking-glass-host.exe
Delete $INSTDIR\LICENSE Delete $INSTDIR\LICENSE.txt
RMDir $INSTDIR RMDir $INSTDIR
@ -125,4 +184,4 @@ LangString DESC_Section4 ${LANG_ENGLISH} "Create start menu shortcut."
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2) !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3) !insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3)
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} $(DESC_Section4) !insertmacro MUI_DESCRIPTION_TEXT ${Section4} $(DESC_Section4)
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END