@echo off
setlocal
Rem ------------------------------------------------------------------------------------------------
Rem PersistentData修復バッチ
Rem 
Rem Copyright (C) 2022 SAY Technologies, Inc. All rights reserved.
Rem 最終修正日：2021/12/02
Rem 第1引数：SRSID
Rem 第2引数：SRS6\bin
Rem 第3引数：$(PersistentDataDir)
Rem ------------------------------------------------------------------------------------------------

SET SRSID=%~1
SET SRSBIN=%~2
SET PERSISTENTDATA_PATH=%~3

REM --- サービス名の確認 ---
SET SERVICE_NAME=BOM8Agent$%SRSID%
IF %SERVICE_NAME%==BOM8Agent$ GOTO ERR_ARG

REM -- SRS6\binフォルダの確認
if not exist "%SRSBIN%" (
	ECHO 「%SRSBIN%」が存在しません。
	goto ERR_ARG
)

REM --- サービスの停止 ---
NET STOP "%SERVICE_NAME%"

REM --- PersistentData修復処理の起動 ---
"%SRSBIN%\PersistentDataRepair.exe" -c "repair" -per "%PERSISTENTDATA_PATH%" -erm 8

REM --- サービスの開始 ---
NET START "%SERVICE_NAME%"

GOTO END_RESTART

:ERR_ARG
ECHO "パラメータエラー"
endlocal
@echo on
exit /b 1


:END_RESTART
endlocal
@echo on
exit /b 0
