:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Setting Parameters
Set Destination=%ProgramFiles%\SIX Payment Services Ltd\MPD(Multi Protocol Driver)


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Testing Administartive permissions
@echo off
cls
ECHO.
Echo Administrative permissions required. Detecting ...

Net Session >nul 2>&1
If %errorLevel% == 0 (
   Echo Success: Administrative permissions confirmed.
   goto Install
) else (
   COLOR 0C
   ECHO.
   ECHO.
   ECHO.ERROR: Logged-on user does not have administrative privilege!
   ECHO.
   ECHO.Logon as administrator or try right click on %0 and select 'Run as administrator'
   ECHO.
   ECHO.
   ECHO.
   PAUSE
   COLOR 07 
   cls
   Exit /B 1
)


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: starting installation
:Install
CD /D "%~dp0"

@echo on

Set /p Version= < Version.cli

Set LinkDestination=%userprofile%\Desktop
Set ProgTitle=SIX ECR Simulator
set ProgExe=clisim.exe

md "%Destination%"

copy ".\%Version%\Windows\eftoa.dll" "%Destination%" /Y
regsvr32 "%Destination%\eftoa.dll" /s

copy ".\%Version%\Windows\%ProgExe%" "%Destination%" /Y

:: Create link destination folder if necessary (see above "LinkDestination"):
if not exist "%linkDestination%" md "%linkDestination%" 

::Comment 
set Comment=SIX ECR VB Sample Program

:: generate temporary VBScript  ... 
echo Set objShell=WScript.CreateObject("Wscript.Shell")>%temp%\CreateShortCut.vbs 
echo Set objShortcut=objShell.CreateShortcut("%linkDestination%\%ProgTitle%.lnk")>>%temp%\CreateShortCut.vbs 
echo objShortcut.TargetPath="%Destination%\%ProgExe%">>%temp%\CreateShortCut.vbs 
echo objShortcut.IconLocation="%Destination%\%ProgExe%,0"
echo objShortcut.Description="%Comment%">>%temp%\CreateShortCut.vbs 
echo objShortcut.WorkingDirectory="%Destination%">>%temp%\CreateShortCut.vbs 
echo objShortcut.Save>>%temp%\CreateShortCut.vbs 

::... execute ... 
cscript //nologo %temp%\CreateShortCut.vbs 

::... delete 
del %temp%\CreateShortCut.vbs



Set Comment=
Set ProgExe=
Set ProgTitle=
Set LinkDestination=
Set Destination=
Set Version=

pause



