Batch Script to Restart Anydesk Service

Asked

Viewed 59 times

0

I need to create a batch scrpit that records the status of Anydesk in a time variable, and if it has the status 'offline' it restarts the Anydesk service. Example:

@echo off
for /f "delims=" %%i in ('"C:\Program Files (x86)\AnyDesk\AnyDesk.exe" --get-status') do set CID=%%i 
echo AnyDesk status is: %CID%
pause

In this example it records the status of Anydesk in the CID variable, so I need to make command loop that when the status is different from online it restarts the service with the command below: Anydesk --Restart-service

1 answer

0

  1. Testing the variable value
if /i not "%CID%" == "online" "C:\Program Files (x86)\AnyDesk\AnyDesk.exe" --restart-service

or

if /i "%CID%" == "offline" "C:\Program Files (x86)\AnyDesk\AnyDesk.exe" --restart-service
  1. To simulate a time loop in time
:VOLTA
@REM Coloque os comandos depois desta linha

PING 127.0.0.1 -n 1 -w 5000 >NUL
@GOTO :VOLTA

Browser other questions tagged

You are not signed in. Login or sign up in order to post.