VNCviewer to Repeater AutoReconnect Feature

Find help for Frequently Asked Questions here - please look here first before posting an already answered question.

VNCviewer to Repeater AutoReconnect Feature

Postby YY » 2009-06-17 15:52

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
nircmdc.exe infobox "Another Session Is Running Already!" "VNCviewer-Repeater AutoReconnection"
goto :END

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 -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

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 -n 1 -w 500 >nul
nircmdc.exe win close title "VNCViewer Message Box"
goto :LOOP_BGN


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 this thread.
Posts: 996
Joined: 2006-11-13 15:11

Re: VNCviewer to Repeater AutoReconnect Feature

Postby YY » 2009-06-18 03:08

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.
Posts: 996
Joined: 2006-11-13 15:11

Return to FAQ

Who is online

Users browsing this forum: No registered users and 4 guests