ken_nogi/bat/カメラサービスの開始・停止バッチファイル/カメラサービスの開始.bat
Kenichiro NOGI 751823a8e0 bat
2025-07-10 10:11:07 +09:00

61 lines
1.4 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
REM #管理者として実行する処理
echo ■■■■■■■■■■■■■■■■■■■■■■
REM 管理者権限で再実行
net session >nul 2>&1
if %errorlevel% neq 0 (
echo ■■■■■■■■■■■■■■■■■■■■■■
echo.
echo このアプリがデバイスに変更を加えることを許可しますか?
echo ポップアップメッセージが出た場合は、「はい」をクリックしてください。
echo.
echo ■■■■■■■■■■■■■■■■■■■■■■
echo.
powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b
)
REM サービス名を指定
set "SERVICENAME=Agent"
REM サービスの状態確認
sc query "%SERVICENAME%" | findstr /I "STOPPED" >nul
if %errorlevel%==0 (
echo.
echo カメラサービス %SERVICENAME% は停止しています。開始します...
sc start "%SERVICENAME%"
REM 開始完了まで待機最大30秒
setlocal enabledelayedexpansion
set "COUNT=0"
:WAITLOOP
sc query "%SERVICENAME%" | findstr /I "RUNNING" >nul
if !errorlevel! neq 0 (
timeout /t 1 >nul
set /a COUNT+=1
if !COUNT! lss 30 goto WAITLOOP
)
endlocal
)
REM 開始確認
sc query "%SERVICENAME%" | findstr /I "RUNNING" >nul
if %errorlevel%==0 (
echo.
echo カメラサービス %SERVICENAME% は正常に開始されました。
) else (
echo.
echo カメラサービス %SERVICENAME% の開始に失敗しました。
)
pause
echo.
echo カメラの閲覧サイトを開きます...
REM 2秒待機
timeout /t 2 >nul
REM 指定URLでChromeを起動
set "URL=http:/localhost:8090/"
start "" "chrome.exe" "%URL%"