@echo off
cls

SET INSTALLFOLDER=imotion64_xp1000r
SET OCXFOLDER=oxcfiles
SET SHORTCUTFOLDER=shortcut

IF "%1" == "/?" GOTO HELP
IF "%1" == "" GOTO HELP
IF "%1" == "?" GOTO HELP
IF "%2" == "/?" GOTO HELP
IF "%2" == "" GOTO HELP
IF "%2" == "?" GOTO HELP
IF "%3" == "/F" GOTO INSTALL 
IF "%3" == "/f" GOTO INSTALL 
IF exist %1\%INSTALLFOLDER% GOTO HELPFORCE

:HELP
echo.
echo  Install Script V1
echo.
echo  To install run again with install [TARGET DRIVE] [SOURCE DRIVE] eg: 
echo.
echo    intall c: e:
echo.
echo  The target drive must be the same as the drive containing windows, in 
echo  most cases this will be drive C
echo.
GOTO END

:HELPFORCE
echo.
echo  Setup has detected the program maybe already installed, if you would 
echo  like to force the installation please use the switch /F eg:
echo.
echo    intall c: e: /F
echo.
GOTO END

:INSTALL

VER | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 GOTO INSTALL2k

VER | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 GOTO INSTALLXP

VER | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 GOTO INSTALL2K3

VER | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 GOTO INSTALLVISTA


GOTO DETECTERROR

:DETECTERROR
echo.
echo A problem has occoured detecting the windows version, please contact Applicam (www.applicam.co.uk)
echo.
GOTO END

:UACINFO
echo.
echo The installer has detected that Vista UAC is turned on, please run msconfig tool, disable UAC
echo once you have done this please reboot and run the installer again.
GOTO END


:INSTALL2k
echo.
echo SYSTEM DETECTED AS MICROSOFT WINDOWS 2000
echo.
copy /y %2\misc\%SHORTCUTFOLDER%\*.* "%1\documents and settings\all users\desktop"
GOTO INSTALLOCX


:INSTALLXP
echo.
echo SYSTEM DETECTED AS MICROSOFT WINDOWS XP
echo.
copy /y %2\misc\%SHORTCUTFOLDER%\*.* "%1\documents and settings\all users\desktop"
GOTO INSTALLOCX


:INSTALL2K3
echo.
echo SYSTEM DETECTED AS MICROSOFT WINDOWS 2003
echo.
xcopy 
copy /y %2\misc\%SHORTCUTFOLDER%\*.* "%1\documents and settings\all users\desktop"
GOTO INSTALLOCX


:INSTALLVISTA
echo.
echo SYSTEM DETECTED AS MICROSOFT WINDOWS VISTA
echo.
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /f EnableLUA | findstr /i "0x1" > nul
IF %ERRORLEVEL% EQU 0 GOTO UACINFO


:INSTALLOCX

echo XX COPY OXC FILES FROM EXISTING FOLDER TO WINDOWS SYSTEM32 FOLDER
copy /y %2\misc\%OCXFOLDER%\*.* %windir%\system32 

echo REGISTER OCX FILES
%1
cd\
cd %windir%\system32
regsvr32 /s vdraw.ocx
regsvr32 /s vdstd.ocx
regsvr32 /s vdgrid.ocx
regsvr32 /s vdopen.ocx
regsvr32 /s comct232.ocx
regsvr32 /s comctl32.ocx
regsvr32 /s mscomm32.ocx
regsvr32 /s mscomctl.ocx
regsvr32 /s ptalkdt.ocx
regsvr32 /s ssa3d30.ocx
regsvr32 /s comdlg32.ocx
regsvr32 /s tabctl32.ocx

copy /y %2\misc\%SHORTCUTFOLDER%\*.* "%1\users\all users\desktop"

GOTO INSTALLMAIN


:INSTALLMAIN
echo .
echo INSTALLING FILES
%1
cd\
mkdir %1\%INSTALLFOLDER%
xcopy %2\%INSTALLFOLDER% %1\%INSTALLFOLDER% /Y /E

echo.
echo  Installation is complete.
echo.

GOTO END


:END
