Subscribe to Windows IT Pro
October 16, 1998 12:00 AM

JSI Tip 0771. A quick way to determine the IPAddress where UserName is logged on from.

Windows IT Pro
InstantDoc ID #72095
Rating: (0)


You can type:

NBTSTAT -c

and receive a display similar to:


Node IpAddress: [0.0.0.0] Scope Id: []
            NetBIOS Remote Cache Name Table
    Name            Type            Host Address    Life [sec]
------------------------------------------------------------
GREYSTONE             UNIQUE      192.168.1.30        010
If the user is not listed, type:

net send jennifer hello
NBTSTAT -c


Node IpAddress: [0.0.0.0] Scope Id: []
              NetBIOS Remote Cache Name Table
    Name            Type            Host Address    Life [sec]
------------------------------------------------------------
JENNIFER              UNIQUE      192.168.1.20        001
GREYSTONE             UNIQUE      192.168.1.30        013
If you need to do this in a batch job, call WhatIP UserName. It will return the whatip environment variable with the IP address, or a 0 if the user is not found.

Example:

call whatip Jennifer
if "%whatip%"

"0" goto notfound

WHATIP.BAT contains:

@echo off
set whatip=
if "%1"

"" goto syntax
set userv=%1
set userv=%userv:"=%
:again
nbtstat -c|find /i "%userv%" > %temp%\where.log
for /f "Tokens=1-7* Delims=. " %%i in (%temp%\where.log) do call :parse "%%i" "%%j" "%%k" "%%l" "%%m" "%%n" "%%o"
if "%whatip%"

"" goto donbt
if exist %temp%\where.log del /q %temp%\where.log
set userv=
goto end
:syntax
@echo Syntax: Where UserName
goto end
:parse
if /i not %1

"%userv%" goto donbt
if /i not %2

"" goto end
set whatip=%4%5%6%7
set whatip=%whatip:""=.%
set whatip=%whatip:"=%
goto end
:donbt
if "%whatip%"

"0" goto end
net send "%userv%" Ignore this interruption
set whatip=0
goto again
:end

You could try using NTNAME instead of NET SEND.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.