通常版
停止
sc stop Jenkins
開始
sc start Jenkins
再起動
set SERVICE_NAME=Jenkins
sc stop %SERVICE_NAME%
sc start %SERVICE_NAME%
自動で管理者権限で処理する版
停止
@echo off
cd /d %~dp0
openfiles > NUL 2>&1
if NOT %ERRORLEVEL% EQU 0 goto promotion
sc stop Jenkins
goto end
:promotion
powershell start-process %~nx0 -verb runas
:end
開始
@echo off
cd /d %~dp0
openfiles > NUL 2>&1
if NOT %ERRORLEVEL% EQU 0 goto promotion
sc start Jenkins
goto end
:promotion
powershell start-process %~nx0 -verb runas
:end
再起動
@echo off
cd /d %~dp0
openfiles > NUL 2>&1
if NOT %ERRORLEVEL% EQU 0 goto promotion
set SERVICE_NAME=Jenkins
sc stop %SERVICE_NAME%
sc start %SERVICE_NAME%
goto end
:promotion
powershell start-process %~nx0 -verb runas
:end
参考サイト様