Searching for VNC servers within a batch
script
This tip is only available for Windows NT. Here's the code:
REM ***********************************************
REM * Search for all VNC servers of your network
REM ***********************************************
REM Date : 04/15/2002
REM Version : 1.0
REM ***********************************************
@echo Off
set break=Off
REM Verifying OS
if not "%ECHO%"=="" echo %ECHO%
if not "%OS%"=="Windows_NT" (goto :errornotnt)
REM *** DON'T FORGET TO EDIT THE SET COMMANDS !! ***
Set scut_location=\\yourcomputer\yourfolder
Set vncviewerpath=c:\progra~1\orl\vnc\vncviewer.exe
REM Main loop
echo Daemonizing VNC server search script ...
echo Do Not close this window or script will die (Press
echo CTRL-C to close)
echo.
call :showheader
echo.
:main
if not exist sites.lst goto :errornolist
echo Calling network scan subs ...
call :scan
echo Sleeping for 30 minutes ...
sleep 1800
if exist %DateString%.lst (del %DateString%.lst /f /q)
goto :main
REM Main part of the script
:scan
for /f "tokens= 1,2,3,4 delims=/ " %%I in ('date /t') do
Call :makedatestring %%J %%K %%L
for /F "tokens= 1,2,3,4,5" %%I in (sites.lst) do
Call :scannetworks %%I %%J %%K %%L %%M
if not exist %DateString%.lst goto :EOF
for /F "tokens= 1,2,3,4 delims=; " %%I in (%DateString%.lst) do
Call :shortcuts %%I %%J %%K %%L
goto :EOF
REM Show header sub
:showheader
echo.
echo That script is an example of the capabities of VNCCSL
echo associated with NT batch scripting language.
echo.
echo Please modify the sites.lst file to reflect your own network
echo architecture. The structure of that file is:
echo "Site name" "command line parameters for vnccsl.exe"
echo Remember: One line per site!
echo.
echo Have fun!
echo.
goto :EOF
REM Scan networks sub
:scannetworks
set VNCCSL_PARAMETERS=%2 %3 %4 %5
@echo Scanning %1 network ...
if exist %DateString%.lst (vnccsl.exe /o:s >> %DateString%.lst)
else (vnccsl.exe /o:s > %DateString%.lst)
goto :EOF
REM Create windows shortcuts sub
:shortcuts
echo Creating shortcuts ...
if not "%2"=="" (makescut.exe /n "%2".lnk /t
%vncviewerpath%\vncviewer.exe
/o /a "/8bit %2" > nul)
if not exist sites (md sites)
echo Moving shortcuts to sites folder ...
move /y *.lnk %scut_location% > nul
goto :EOF
REM Extratcing current date sub
:makedatestring
set DateString=%3%1%2
set Day=%2
set Month=%1
set Year=%3
goto :EOF
REM Error subs
:errornotnt
echo This script requires Windows NT or Windows 2000 ...
goto :end
:errornolist
echo Can't find any sites.lst file ...
goto :end
:end
Don't forget to edit the set command to use it and to create a sites.lst text file!
The script code may be downloaded here.
MAKESCUT.EXE utility may be found here for free.
SLEEP.EXE is part of the Microsoft Resource Kit.
|