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

VNCviewer to Repeater AutoReconnect Feature

Post Reply
YY
200
200
Posts: 996
Joined: 2006-11-13 15:11

VNCviewer to Repeater AutoReconnect Feature

Post by YY »

As we know, the VNCviewer has an option to set the "number of times the reconnect is" (at the "Option" window). This is used to make the viewer to autoreconnect to the remote server -- in case the connection dropped due to network problem, or server restart, or etc. However this feature supports ONLY the direct connection. If the connection is via repeater, no matter mode I or Mode II operation, we are out of luck (on the other hand, the server does support the autoreconnect to a repeater).

An unfortunate situation is that: the repeater has a timeout feature, that means if it cannot establish the connetion for the two parties within serveral minutes, it simply remove it(them) from the list, and a message box will then be popup at the viewer pc. So if you want to retry, you need to (close the message box, and) click the "Connect" (or re-run your script) again (& Again) Manually.


To solve this problem, I write a small batch file to do this job (close the message box, and re-run a script) for me. Here is what we need:
1. The vncviewer.exe -- I rename it as vncviewer-sp.exe, use it only for this batch file.
2. NirCmdc.exe -- a free tool available at NirSoft. I use it to auto close the viewer message box (if connection is dropped)
3. config-sp.vnc -- the connection file, which save the connecting information, you can create your copy during a successful connection (of course, using the repeater)
4. v2r-autoreconnect.bat -- This is the batch file to do the said job, here is the content:
rem ===========================
rem v2r-autoreconnect.bat
rem ===========================


@echo off

rem ===== Following Code check if the vncviewer-sp.exe is alreading running ======
tasklist | find /i "vncviewer-sp.exe" >nul
if ERRORLEVEL 1 goto :LOOP_BGN
nircmdc.exe infobox "Another Session Is Running Already!" "VNCviewer-Repeater AutoReconnection"
goto :END


:LOOP_BGN
rem ===== Following Code Check the status of vncviewer-sp.exe for every 7 second
rem ===== If the vncviewer-sp.exe is not running, start it.
ping 1.1.1.1 -n 1 -w 7000 >nul
tasklist | find /i "vncviewer-sp.exe" >nul
if ERRORLEVEL 1 start vncviewer-sp.exe -config config-sp.vnc

rem ===== Following statement shows another method to start the vncviewer-sp.exe,
rem ===== if you don't want to use a .vnc file.
rem if ERRORLEVEL 1 start vncviewer-sp.exe -connect ID:1235 -nostatus -proxy uvnc.com:5901


rem ==== The next statement check if the "VNCViewer Message Box" appear,
rem ==== if this happened means the connection to repeater is broken,
rem ==== then close it (this make the vncviewer-sp.exe terminate too, loopback to start again
ping 1.1.1.1 -n 1 -w 500 >nul
nircmdc.exe win close title "VNCViewer Message Box"
goto :LOOP_BGN



:END
When all ready, put all the files into a separate folder, which including all the files mentioned, and

also the dsmplugin & key if you use encryption.

To Start, just run the v2r-autoreconnect.bat

To Stop, close the CMD Window opened by v2r-autoreconnect.bat. But the vncviewer-sp.exe may be stilling running, you need to stop it with the TaskMgr, or using the Taskkill command.

To create config-sp.vnc, you may reference [topic=15484]this thread[/topic].
YY
200
200
Posts: 996
Joined: 2006-11-13 15:11

Re: VNCviewer to Repeater AutoReconnect Feature

Post by YY »

Forget to mention, I test the batch script on my WinXP Pro-SP2 only.

I don't have a Vista system :-] , not sure if any problem (UAC, several folders are protected, etc) may arised.
Post Reply