@setlocal enableextensions
@cd /d "%~dp0"

Set ProgramName=OptecTCF-S_Installer
Set FileVersion=(6.0.6)
Set Product=TCF-S
Set Company=Optec
Set "RegisterProgram=ASCOM.OptecTCF_S.Server.exe"

::Determine if 32 or 64 bit
@echo OFF
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OSTYPE=32BIT || set OSTYPE=64BIT

if %OSTYPE%==32BIT (GOTO 32BIT)
if %OSTYPE%==64BIT (GOTO 64BIT)


::Most XP Machines are 32 but this is possible
:64BIT
echo installing for 64 bit OS
echo Press Enter to Continue if this is correct, Close this window to exit
pause
echo Installing...

msiexec /a "%ProgramName%%FileVersion%.msi" /qb TARGETDIR="C:\Program Files (x86)\%Company%\%Product%"
"C:\Program Files (x86)\%Company%\%Product%\Application Files\%RegisterProgram%" -register
%SystemRoot%\explorer.exe "C:\Program Files (x86)\%Company%\%Product%\Application Files\
GOTO END



::Most XP Machines are 32 but this is possible
:32BIT
echo installing for 32 bit (x86) OS
echo Press Enter to Continue if this is correct, Close this window to exit
pause
echo Installing...

msiexec /a "%ProgramName%%FileVersion%.msi" /qb TARGETDIR="C:\Program Files\%Company%\%Product%"
"C:\Program Files\%Company%\%Product%\Application Files\%RegisterProgram%" -register
%SystemRoot%\explorer.exe "C:\Program Files\%Company%\%Product%\Application Files\
GOTO END


:END
echo Complete
echo You may need to create shortcuts to TCF-S Commander.exe by hand. This script should have opened the installation folder
pause