Files
Misc-Scripts/Veeam-Services-Control.cmd

33 lines
1009 B
Batchfile

@echo off
fsutil dirty query "%SystemDrive%">nul 2>&1 || "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -Command "Start-Process '%~f0' -Verb RunAs" 2>nul && goto :eof || goto :eof
:menu
set switch=
set start=
cls
echo Veeam Services Control
echo ----------------------
echo 1) Start
echo 2) Stop
echo 3) Restart
echo ----------------------
choice /c:123 /n /m "#: "
if "%errorlevel%"=="1" set switch=start
if "%errorlevel%"=="2" set switch=stop
if "%errorlevel%"=="3" (
set switch=stop
set start=true
)
for /f "tokens=2" %%? in ('sc query type^= service state^= all^|find /i "veeam"^|find /i /v "sqlagent"^|find /i "postgresql-x64-15"') do net %switch% /y "%%?"
if "%switch%"=="stop" for /f "tokens=3*" %%? in ('tasklist /fo list^|find /i "veeam"') do taskkill /f /im "%%?"
if "%start%"=="true" for /f "tokens=2" %%? in ('sc query type^= service state^= all^|find /i "veeam"^|find /i /v "sqlagent"^|find /i "postgresql-x64-15"') do net start /y "%%?"
echo ""
#pause
#goto menus
:eof