Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

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

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

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