echo off
chcp 1250
setlocal ENABLEDELAYEDEXPANSION
TITLE Nastaveni Bentley MicroStation V8i SS4
::ü‡«ěőŘ˙ó' Şe‡tina Latin2

setlocal ENABLEDELAYEDEXPANSION
::color 02
mode con:cols=120 lines=70

::echo Řçźý§ě ˇ‚ ¬eçtina Latin2

echo          ######################################################
echo          #                    CONFIGURATION                   #
echo          #        Microstation CONNECT Edition + Groma13      #
echo          ######################################################
echo          Tested with Win 10 x64
echo          Version: 2022-07-21
echo. 
echo          Press any key to begin...
pause >nul
cls
echo.

set scriptdir=%~dp0
set scriptdir=%scriptdir:~0,-1%

set x86=x86
set x64=AMD64

set x86count=
set x64count=


:: ************************************************* Priprava *************************************************
::detekce architektury systému z registrů
for /f %%m in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE^|find /i /c "%x86%"') do set x86count=%%m
for /f %%n in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE^|find /i /c "%x64%"') do set x64count=%%n

echo x86count %x86count%
echo x64count %x64count%


:: ************************************************* Kontrola detekce *************************************************
if "%x86count%"=="1" if "%x64count%"=="1" (
  echo chyba detekce architektury
  pause
  goto eof
  )

if "%x86count%"=="0" if "%x64count%"=="0" (
  echo chyba detekce architektury
  pause
  goto eof
  )  
:: ---------------------------------------------------------------------------------------------------------------------  
  

if "%x64count%"=="1" (
  set progfiles64="%programW6432%"
  set installdir_CE="%ProgramFiles%\Bentley\MicroStation CONNECT Edition\MicroStation"
  set groma="%scriptdir%\Groma\x64"
  set configuration_CE="%ProgramData%\Bentley\MicroStation CONNECT Edition\Configuration" 
  echo Detected system type: x64
  )


set installdir_CE=%installdir_CE:~1,-1%
set groma=%groma:~1,-1%
::set configuration_CE=%configuration_CE:~1,-1%

pause

:: ************************************************* kopirovani *************************************************
::
:: MicroStation CONNECT Edition
if exist %installdir_CE% (
    echo Copy tools from %scriptdir%\ to %installdir_CE%
    xcopy "%scriptdir%\Installdir\*" "%installdir_CE%" /W/Y/H/R/I/K/E
    xcopy "%scriptdir%\Groma\*.cfg" "%installdir_CE%\config\appl" /W/Y/H/R/I/K/E
	xcopy "%scriptdir%\ProgramData\*" %configuration_CE% /W/Y/H/R/I/K/E
    
    )

::

pause	

::----------------------------------------------------------------------
::

echo Copy tools to %USERPROFILE%\AppData\Roaming
xcopy "%scriptdir%\Profile\*.*" "%USERPROFILE%\AppData\Roaming" /W/Y/H/R/I/K/E
::----------------------------------------------------------------------


echo.

echo Install font
xcopy "%scriptdir%\Fonts\ISOCPEUR.ttf"  %systemroot%\fonts /W/Y/H/R/I/K/E
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "ISOCPEUR (True Type)" /t REG_SZ /d "ISOCPEUR.ttf" /f

::----------------------------------------------------------------------

echo 		Press any key to close.
pause >nul
cls
exit