@echo off
REM  RAID800                               
REM  Perl Install tool for RAID800 SVP
REM       All Rights Reserved, Copyright (C) 2020,Hitachi, Ltd. 
REM
REM History  :Version    :DATE        : Coder        : Patch No
REM RAID 800 
REM          :01-00      :2020.01.28  : T.Yamanaka   : #97547 (Strawberry Perl 5.28.2 is supported) 
REM
REM Document
REM   MSI File Installer 
REM Required Environment 
REM   PerlName ,MsiFile  ,GUID
REM

if "'%PerlName%'" equ "''" (
	echo Environment Error PerlName
	exit /b 1
)

if "'%MsiFile%'" equ "''" (
	echo Environment Error MsiFile
	exit /b 1
)

if "'%GUID%'" equ "''" (
	echo Environment Error GUID
	exit /b 1
)

call :Install_check
set BF_CHK=%ERRORLEVEL%
if %BF_CHK% equ 0 (
	echo Skip the %PerlName% installation.
	exit /b 2
)

echo %PerlName% installation start
start /wait msiexec.exe /package %MsiFile% /qn /L*v C:\Perl_Install.log /norestart
set INS_ERR=%ERRORLEVEL%
if not %INS_ERR% equ 0 (
	echo %PerlName% installation failed INSTALL_ERROR:%INS_ERR%
	exit /b 1
)

call :Install_check
set AF_CHK=%ERRORLEVEL%
if not %AF_CHK% equ 0 (
	echo %PerlName% installation failed REG_CHK_ERROR:%AF_CHK%
	exit /b 1
)

echo %PerlName% installation succeeded.

exit /b 0

:Install_check
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%GUID%" /v DisplayName  /reg:64 > nul 2>&1
exit /b %ERRORLEVEL%

