2008-11-15

Launch TightVNC using the Computer Name - or - How to Get IP from Computer Name in MS-DOS cmd.exe batch file





  • First, knowing the name of a computer, we want to get its IP. The script 'GetIpFromName' does that..
  • Second, we need to call `StartVncViewer MyServerName` to start VncViewer..

    See scripts below:

    @setlocal
    @ping -n 1 %~2 | find "Pinging" > %TEMP%\ADDR_IPv4.txt
    @for /F "tokens=2 delims=[]" %%a in (%TEMP%\ADDR_IPv4.txt) do @set ip=%%a
    @endlocal & set "%~1=%ip%"
    @REM USAGE: @call StartVncViewer MyComputerName
    @setlocal
    @call GetIpFromName ip "%~1"
    @pushd C:\Progra~1\TightVNC
    @start vncviewer.exe %ip%
    @popd
    @endlocal

  • No comments:

    Post a Comment