2009-01-15

Launch TightVNC using the Computer Name - or - How to Get IP from Computer Name in MS-DOS Batch

First, knowing the name of a computer, we want to get its IP. The script below does it for you. I called it 'GetIpFromName.bat' and I put the IP in a variable called 'GetIpFromName':.


@%COMSPEC%\..\ping.exe -n 1 %~1 | %COMSPEC%\..\find.exe "Pinging" > %TEMP%\TEMPIP.txt
@for /F "tokens=2 delims=[]" %%a in (%TEMP%\TEMPIP.txt) do set _GetIp=%%a



Then we need to call 'GetIpFromName.bat' and launch VncViewer. I called the script 'StartVncViewer.bat'.

Finally, if I often need to access a computer called, say, Bambi, I create a script called 'VncBambi.bat' on my desktop.

Update 2013: consider tweaking variables for the appropriate viewer: legacy (vncviewer.exe) vs. 2.x+ (tvnviewer.exe)

No comments:

Post a Comment