REM  Hitachi SVP                              
REM  JAVA Update tool for Hitachi SVP
REM                 Copy right. 2015  Hitachi. Ltd. 
REM
REM History  :Version    :DATE        : Coder        : Patch No
REM Hitachi SVP
REM          :01-01      :2015.05.21  : S.Moriya  : Y8012222998 (New)
REM          :01-02      :2016.04.01  : H.Yasukawa: Y8792223590
REM          :01-03      :2018.02.16  : Y.Kumagai : #44854 (Remote Micro Exchange Support)

REM

echo off

REM whoami /group
for /f "tokens=1 delims=," %%i in ('whoami /groups /FO CSV /NH') do (
	if "%%~i"=="BUILTIN\Administrators" set ADMINISTRATOR=yes
	if "%%~i"=="Mandatory Label\High Mandatory Level" set ELEVATED=yes
	if "%%~i"=="Mandatory Label\System Mandatory Level" set ELEVATED=yes
)

REM Administrator user check
if "%ADMINISTRATOR%" neq "yes" (
	echo Not the Administrator user. Run the Administrator user
	pause
	exit 1
)

REM Elevation check
if "%ELEVATED%" neq "yes" (
	echo Must be "run as Administrator"
	pause
	exit 1
)

REM Administrator's usernmae check Y8792223590
set EXIST_ADMINISTRATOR=no
set EXIST_XADMINISTRATOR=no

for /f "tokens=1" %%i in ('wmic useraccount get name') do (
	if /i "%%~i"=="Administrator" set EXIST_ADMINISTRATOR=yes
	if /i "%%~i"=="xadministrator" set EXIST_XADMINISTRATOR=yes
)

if "%EXIST_ADMINISTRATOR%" neq "yes" if "%EXIST_XADMINISTRATOR%" neq "yes" (
	echo Error.
	echo Please check the name of the Built-in Administrator of the Windows OS.
	echo If it is not Administrator or xadministrator, you have to change the name of the Built-in Administrator to Administrator or xadministrator.
	echo If you can not change the name of the Built-in Administrator, call support center.
	pause
	exit 1
)

exit /b 0
