@echo off
call check-for-admin
if %ERRORLEVEL% neq 0 exit /b

set EXE=..\software\citrixworkspace-setup.exe
set EXE2=..\software\nsepa_setup.exe
set MSI=ICAWebWrapper.msi
set CITRIXROOT="%ProgramFiles(x86)%\Citrix"

if NOT EXIST %EXE% (
  echo ERROR: %EXE% not found!
  echo GOTO: https://www.citrix.com/de-de/downloads/workspace-app/workspace-app-for-windows-long-term-service-release 
  echo and save the file as "citrixworkspace-setup.exe" in folder "software"!
  echo.
  pause
  exit /b
)

if NOT EXIST %EXE2% (
  echo ERROR: %EXE2% not found!
  echo get the file and save it in folder "software"!
  echo.
  pause
  exit /b
)

echo ####### %0 #######

echo installing Citrix Workspace LTS ...
start /wait %EXE% /silent /noreboot /AutoUpdateCheck=disabled

echo disabling autostart for Citrix Workspace ...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run32" ^
  /v "ConnectionCenter" /d 0300000065d2d743d402d701 /t REG_BINARY /f

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run32" ^
  /v "Redirector" /d 030000005e06c842d402d701 /t REG_BINARY /f

echo installing Citrix gateway endpoint Analysis Plug-in ...
start /wait %EXE2%

echo installing Citrix ICA web wrapper ...
cd %CITRIXROOT%\"Citrix Workspace*"

if NOT EXIST %MSI% (
  echo ERROR: %MSI% not found!
  echo ####### %0 #######
  pause
  exit /b
)

@echo on
msiexec /i %MSI% /quiet
@echo off

echo ####### %0 #######
pause

