:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Setting Parameters
Set Destination=%ProgramFiles%\SIX Payment Services Ltd\MPD(Multi Protocol Driver)
Set TraceDestination=%SystemDrive%\Trace
Set Protocol=/Protocol VEZP /OPI
Set Port=/Port \\.\COM1
Set Speed=/Speed 115200
Set Other=/NoProbe /AutoStart /NoSerialPortScan
Set Opi=

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: 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.srv

Set ServiceDisplayName=SIX MPD(Multi Protocol Driver)


Set StartUpParameter=%Protocol% %Port% %Speed% %Other% %Opi% /TraceDir %TraceDestination%

net stop eftmpd

".\%Version%\Windows\eftdvs.exe" /UnRegServer

md "%Destination%"
md "%TraceDestination%"

copy ".\%Version%\Windows\dzip32.dll" "%Destination%" /Y
copy ".\%Version%\Windows\eftdvs.exe" "%Destination%" /Y

del "%Destination%\eftdvscfg.xml"
ECHO %StartUpParameter% > "%Destination%\eftdvs.cfg"
"%Destination%\eftdvs.exe" /Service /Autostart

sc config eftmpd displayname= "%ServiceDisplayName%"
sc description eftmpd "Runs SIX MPD(Multi Protocol Driver) %Version%"
sc failure "eftmpd" reset= 300 command= "" actions= restart/10000/restart/20000/restart/30000


net start eftmpd

Set Destination=
Set Port=
Set Speed=
Set Other=
Set Opi=
Set StartUpParameter=
Set Version=

pause
