Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://twitter.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

Script: Check if VNC-Server is frozen

Developers may discuss here
Post Reply
User avatar
Rhino Cracker
Posts: 5
Joined: 2011-12-01 12:53

Script: Check if VNC-Server is frozen

Post by Rhino Cracker »

Hi all, I'm not sure, whether this is the right subforum for it, but I wanted to share something with you.
I oftenly faced the issue that my VNC-Server is frozen.
So I've written small script using NCat (from NMap) that checks, whether the server is still responding, and restarts it if necessary:

UltraVNCServerWatchdog.bat

Code: Select all

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

REM newer versions of NCAT can be found here: https://nmap.org/download.html
REM XP-compatible version is here: https://nmap.org/dist/nmap-6.47-win32.zip
set netcat=R:\Programme\DOS\nmap-6.47\ncat.exe
set outfile="out.txt"
set vncserver="D:\Programme\UltraVNC\winvnc.exe"
del %outfile%

set found=0
FOR /F "delims=" %%A IN ('echo Hello ^| %netcat% -4 -i 1 127.0.0.1 5900 -o out.txt') DO (
REM for each line
  if "%%A"=="RFB 003.008" (
    set found=1
  )
  echo line: %%A
  echo found: !found!
)
echo found final: %found%
echo.

if %found%==1 (
  echo UltraVNC-Server is responding correctly ==^> do nothing and exit
  goto :end
) else (
  echo UltraVNC-Server doesn't respond ==^> Restart it:
  echo Taskkilling:
  TaskKill /F /IM winvnc.exe
  echo Restarting:
  start "" %vncserver%
  echo %DATE% %TIME% restarted UltraVNC-Server >> UVNC-Restart-Log.txt
)



:end
echo EXIT
REM win10 only:
timeout /T 600
REM if existing:
REM warten.exe 600000
REM if not:
REM ping 127.0.0.1 -n 600 > NUL
REM this just keeps the cmd window open for a bit so you might find it when connecting.
It's built on the fact, that uvncs will respond with RFB 003.008 to any packet sent to it - as long as it's not frozen, of course. :)
The script is properly running on a XP machine. The testing part can also work with Win10 (or any in between). However, you might have to modify the start "" %vncserver% line (to start for the correct user) and/or give the script admin privileges to kill the running+frozen winvncs.exe.
Image
Post Reply