Script Examples for Windows NT/XP

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 11:20, 19 June 2007 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Script Example A =

BEGIN
::Do a netstat without included name resolution;
::find connection on port 5631 (pcAnywhere).
netstat -a -n|findstr "5631" >A.txt 2>nul
::Parse the IP address out of the returned string.
for /f "tokens=4 delims=: " %%a in (A.txt) do call :GETNAMES %%a goto :cleanup


:GETNAMES
::Do nbtstat to the remote IP address, and parse out the ::<20> name, which is the NetBIOS name of the PCA Client. if %1==0.0.0.0 g

oto :EOF nbtstat -A %1|findstr "<20>" >>B.txt ::Errorlevel 1 is returned if the above findstr was unsuccessful; ::tell user and quit . IF errorlevel 1 (echo No PCA connection exists) & goto :CLEANUP ::NetBIOS creates <03> entries for username and machinename; ::get

them with nbtstat to the remote machine and print out. for /f "tokens=1" %%a in (B.txt) do nbtstat -a %%a|findstr "<03>"


:CLEANUP
if exist A.txt del A.txt
if exist B.txt del B.txt