Assuming you can ping the computer, here's an attempt to accomplish what you want.
There's a 6 second wait in the script to allow time to close the prompt notifying that the password was wrong. If it is not closed in time, it cannot read the log file to determine if the previous attempt was successful or not. If you cannot test if the computer is online prior to connecting with uVNC, then you'll likely need to increase the wait time to 25+ seconds to account for the viewer timeout.
The script could also be modified to connect to the computer twice using each password so you don't have to deal with closing the prompt, but you will have to eventually close out of the window that used the wrong password. If you know what computers have which password, then you could query two different files of computer names and use the correct password out of the gate.
Code: Select all
@Echo Off
If %11 == 1 Goto NoIP
Set IPAddr=%1
Ping %IPAddr% -n 1 > NUL
If %ErrorLevel% EQU 1 (Goto:OFFLINE) else (echo Computer ONLINE)
Start C:\Data\VNCViewer.exe /password Password1 /logfile uVNC.log %IPAddr%
Choice /N /T 6 /D Y /M "Connecting with 1st password..."
Find /I "VNC authentication failed!" uVNC.log > NUL
Del uVNC.log
If %ErrorLevel% == 1 Goto End
If %ErrorLevel% == 0 Goto Auth2
:Auth2
Echo Connecting with 2nd password...
Start C:\Data\VNCViewer.exe /password Password2 %IPAddr%
Goto End
:NoIP
Echo.
Echo No IP address was specified
Echo.
Echo.
Goto End
:OFFLINE
Echo.
Echo The computer (%IPAddr%) is currently unreachable
Echo.
Echo.
Goto End
:End
[EDIT1] I swapped the two If %ErrorLevel% lines as I had them backwards.
[EDIT2] Working on a problem where it always tries to connect with the 2nd password when the 1st password worked and connected. Meh, sometimes it does that and sometimes it doesn't depending on when the viewer executable releases the lock on the log file. If nothing else, this is a start of a solution.