@echo off
echo Downloading, Installing, and Configuring the BMC Pulse Secure VPN client.
echo
echo .
echo .
echo .
echo Please leave this window open until the installation completes.
echo This window will close upon completion.
echo .
echo ..
echo ...
echo Checking for x86 or x64 OS
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT 
if %OS%==32BIT goto 32bit
if %OS%==64BIT goto 64bit
goto end
:32bit
echo ...
echo Downloading x86 Installer from https://www.bmc.org/hd/
powershell.exe Invoke-WebRequest -OutFile %temp%\Default.pulsepreconfig http://www.bmc.org/sites/default/files/hd/default.pulsepreconfig
powershell.exe Invoke-WebRequest -OutFile %temp%\ps-pulse-win-9.1r15.0-b15819-32bit-installer.msi http://www.bmc.org/sites/default/files/hd/ps-pulse-win-9.1r15.0-b15819-32bit-installer.msi
echo ... Installing Pulse Secure
msiexec /i %temp%\ps-pulse-win-9.1r15.0-b15819-32bit-installer.msi CONFIGFILE=%temp%\Default.pulsepreconfig /qb 
goto end
:64bit
echo ...
echo Downloading x64 Installer from https://www.bmc.org/hd/
powershell.exe Invoke-WebRequest -OutFile %temp%\Default.pulsepreconfig http://www.bmc.org/sites/default/files/hd/default.pulsepreconfig
powershell.exe Invoke-WebRequest -OutFile %temp%\ps-pulse-win-9.1r15.0-b15819-64bit-installer.msi http://www.bmc.org/sites/default/files/hd/ps-pulse-win-9.1r15.0-b15819-64bit-installer.msi
echo ... Installing Pulse Secure
msiexec /i %temp%\ps-pulse-win-9.1r15.0-b15819-64bit-installer.msi CONFIGFILE=%temp%\Default.pulsepreconfig /qb
goto end
:end
echo ...
echo Cleaning up temp files
echo .
echo ..
echo ...
IF EXIST %temp%\Default.pulsepreconfig DEL /F %temp%\Default.pulsepreconfig
IF EXIST %temp%\ps-pulse-win-9.1r15.0-b15819-32bit-installer.msi DEL /F %temp%\ps-pulse-win-9.1r15.0-b15819-32bit-installer.msi
IF EXIST %temp%\ps-pulse-win-9.1r15.0-b15819-64bit-installer.msi DEL /F %temp%\ps-pulse-win-9.1r15.0-b15819-64bit-installer.msi
exit