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

53 lines
1.3 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 "RUNNING" >nul
if %errorlevel%==0 (
echo.
echo カメラサービス %SERVICENAME% は起動中です。停止します...
sc stop "%SERVICENAME%"
REM 停止完了まで待機最大30秒
setlocal enabledelayedexpansion
set "COUNT=0"
:WAITLOOP
sc query "%SERVICENAME%" | findstr /I "STOPPED" >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 "STOPPED" >nul
if %errorlevel%==0 (
echo.
echo カメラサービス %SERVICENAME% は停止しています。
) else (
echo.
echo カメラサービス %SERVICENAME% の停止に失敗しました。
)
pause