Skip to content

Instantly share code, notes, and snippets.

@janasco
Created August 3, 2023 09:46
Show Gist options
  • Select an option

  • Save janasco/c6168d17ed6eb4b6eaf7fd46fb775f60 to your computer and use it in GitHub Desktop.

Select an option

Save janasco/c6168d17ed6eb4b6eaf7fd46fb775f60 to your computer and use it in GitHub Desktop.
AnyDesk Reset
@echo off & setlocal enableextensions
title Reset AnyDesk
reg query HKEY_USERS\S-1-5-19 >NUL || (echo Please Run as administrator.& pause >NUL&exit)
chcp 437
call :stop_any
del /f "%ALLUSERSPROFILE%\AnyDesk\service.conf"
del /f "%APPDATA%\AnyDesk\service.conf"
copy /y "%APPDATA%\AnyDesk\user.conf" "%temp%\"
rd /s /q "%temp%\thumbnails" 2>NUL
xcopy /c /e /h /r /y /i /k "%APPDATA%\AnyDesk\thumbnails" "%temp%\thumbnails"
del /f /a /q "%ALLUSERSPROFILE%\AnyDesk\*"
del /f /a /q "%APPDATA%\AnyDesk\*"
call :start_any
:lic
type "%ALLUSERSPROFILE%\AnyDesk\system.conf" | find "ad.anynet.id=" || goto lic
call :stop_any
move /y "%temp%\user.conf" "%APPDATA%\AnyDesk\user.conf"
xcopy /c /e /h /r /y /i /k "%temp%\thumbnails" "%APPDATA%\AnyDesk\thumbnails"
rd /s /q "%temp%\thumbnails"
call :start_any
echo *********
echo Completed.
echo(
goto :eof
:start_any
sc start AnyDesk
sc start AnyDesk
if %errorlevel% neq 1056 goto start_any
set AnyDesk1=%SystemDrive%\Program Files (x86)\AnyDesk\AnyDesk.exe
set AnyDesk2=%SystemDrive%\Program Files\AnyDesk\AnyDesk.exe
if exist "%AnyDesk1%" start "" "%AnyDesk1%"
if exist "%AnyDesk2%" start "" "%AnyDesk2%"
exit /b
:stop_any
sc stop AnyDesk
sc stop AnyDesk
if %errorlevel% neq 1062 goto stop_any
taskkill /f /im "AnyDesk.exe"
exit /b
@ROMANOFFCUR
Copy link

@echo off
setlocal enableextensions
title Reset AnyDesk ID

:: 1. Verificar permisos de Administrador
reg query HKEY_USERS\S-1-5-19 >NUL || (
echo Por favor, ejecuta este archivo como Administrador.
pause
exit
)

chcp 437 >NUL

echo Deteniendo AnyDesk...
call :stop_any

echo Realizando copia de seguridad de configuracion de usuario...
:: Borra ID antigua
del /f "%ALLUSERSPROFILE%\AnyDesk\service.conf" 2>NUL
del /f "%APPDATA%\AnyDesk\service.conf" 2>NUL
del /f "%ALLUSERSPROFILE%\AnyDesk\system.conf" 2>NUL
del /f "%APPDATA%\AnyDesk\system.conf" 2>NUL

:: Backup de preferencias y miniaturas
copy /y "%APPDATA%\AnyDesk\user.conf" "%temp%" >NUL 2>NUL
rd /s /q "%temp%\thumbnails" 2>NUL
xcopy /c /e /h /r /y /i /k "%APPDATA%\AnyDesk\thumbnails" "%temp%\thumbnails" >NUL 2>NUL

:: Limpieza de archivos
del /f /a /q "%ALLUSERSPROFILE%\AnyDesk\ad_" 2>NUL
del /f /a /q "%APPDATA%\AnyDesk\ad_
" 2>NUL

echo Reiniciando AnyDesk para generar nueva ID...
call :start_any

:: Espera a que se genere el archivo de sistema con la nueva ID
:lic
timeout /t 2 /nobreak >NUL
if exist "%ALLUSERSPROFILE%\AnyDesk\system.conf" (
type "%ALLUSERSPROFILE%\AnyDesk\system.conf" | find "ad.anynet.id=" >NUL
if !errorlevel! equ 0 goto restore
)
if exist "%APPDATA%\AnyDesk\system.conf" (
type "%APPDATA%\AnyDesk\system.conf" | find "ad.anynet.id=" >NUL
if !errorlevel! equ 0 goto restore
)
:: Si tarda mucho, salimos del bucle para no congelar
goto restore

:restore
echo Restaurando configuracion de usuario...
call :stop_any
move /y "%temp%\user.conf" "%APPDATA%\AnyDesk\user.conf" >NUL 2>NUL
xcopy /c /e /h /r /y /i /k "%temp%\thumbnails" "%APPDATA%\AnyDesk\thumbnails" >NUL 2>NUL
rd /s /q "%temp%\thumbnails" >NUL 2>NUL

echo Iniciando AnyDesk final...
call :start_any
echo *********
echo Completado.
echo(
pause
goto :eof

:: FUNCIONES

:start_any
:: Intenta iniciar servicio (si existe)
sc start AnyDesk >NUL 2>NUL
:: Busca ejecutables comunes
set AnyDesk1=%SystemDrive%\Program Files (x86)\AnyDesk\AnyDesk.exe
set AnyDesk2=%SystemDrive%\Program Files\AnyDesk\AnyDesk.exe
if exist "%AnyDesk1%" start "" "%AnyDesk1%"
if exist "%AnyDesk2%" start "" "%AnyDesk2%"
exit /b

:stop_any
:: Intenta detener servicio (sin bucle infinito)
sc stop AnyDesk >NUL 2>NUL
:: Mata el proceso forzosamente por si es portable
taskkill /f /im "AnyDesk.exe" >NUL 2>NUL
exit /b

@ROMANOFFCUR
Copy link

This file worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment