Remote Computer Info

jimmyhtn
jimmyhtn used Ask the Experts™
on
Hi,

Could someone provide a VB script so every time I run this script, it will prompt for the user name then display his/her remote computer IP address or naming convension info?  Bat script would also acceptable.  
(Example: after you input their username, hit Submit or Enter then short report showing their computer info.

Thank you and have nice day :)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Hi,

I didn't encounter such program/script before but it can be done. Please see below link.
http://www.secnewsgroups.net/windowssecurity/t471-how-find-what-computer-user-logged.aspx

If you want to know who is currently logged on to that particular computer, you can use LoggedOn2 program.
http://www.nonags.com/freeware-loggedon2-1-02_1863.html

Here's a script to get the remote computers' info.
http://www.visualbasicscript.com/m43354.aspx
First thing to clear ist that tha IP is related to computer name not the user name logged on that PC.
Now, depending on how much info do you want from that PC and depending on your network configuration, you can have the computer IP (if this is the only information you need) by just a simple PING.
For example you can execute this command at a MS DOS prompt:

ping computername

This should be return at the first line: "Pringing ComputerName [ip addredd in dotted format] with 32 bytes of data", then if you PC is on-line you'll have the 4 responses with "Reply from..." or "Request timed out".
If the name could not be resolved it will give you and error message telling you that teh "host could not be found"...
Premkumar YogeswaranSr. Analyst - System Administrator

Commented:
It is a VB Script...!
It will show the current user in Remote system..!
strComputer = inputbox("Please enter the name of the computer:")

' Check that user entered a value
if strComputer = "" then
	wscript.quit
end if

ON ERROR RESUME NEXT ' Handle errors connecting to the computer (Not switched on, permissions error etc)
set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "")

if err <> 0 then ' Check for error
	wscript.echo "Error connecting to specified computer: " & err.description
	wscript.quit
end if
ON ERROR GOTO 0 ' Turn off resume next error handling

set colOS = objWMI.ExecQuery("Select * from Win32_ComputerSystem")

For Each objItem In colOS
	if strUsers <> "" then
		strUsers = strUsers & ", " & objItem.UserName
	else
		strUsers = objItem.UserName
	End If
Next

wscript.echo "The following user(s) are logged on to " & strComputer & ":" & strUsers

Open in new window

11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Use NBTscan. it is a freeware and can easily solve your problem.

Author

Commented:
I just need a brief remotely VBscript to display their computer Name or IP Address by typing in their Username.
Premkumar YogeswaranSr. Analyst - System Administrator

Commented:
Hi,
With user name we cannot resolve System Name or IP Address...!

Only DNS can help in converting user name to IP and IP to user name.

No Script can be created in this way...! By using User name to find the computer details..!

We can find the Computer details by Computer name and IP Address...!

Prem
No Premglitz scripts can be written for this purpose. Here i am writting a batch script which take user name as input and display computer name on which that user is logged in. What you have to do is copy and paste this script on notepad and save it with anyname but the extension should be .cmd or .bat forexample "username.cmd"

@ECHO OFF

:GETUSERNAME
ECHO.
SET UName=
SET /P UName=Enter Username for %USERDOMAIN%:
IF [%UName%]==[] (
      ECHO Please provide username.
      CALL :GETUSERNAME)

NET USER "%UName%" /DOMAIN 2>NUL>NUL
IF ERRORLEVEL 1 (
      ECHO Username not found in Active Directory.
      GOTO :GETUSERNAME)

      ECHO Please wait... &ECHO.
      FOR /F "delims=\\ " %%c IN ('NET VIEW ^|FIND "\\"') DO (
      PING -n 1 -l 10 -w 100 %%c |FIND /I "TTL" >NUL
      IF NOT ERRORLEVEL 1 (
            REG QUERY "\\%%c\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName |FIND /I "%UName%" >NUL
            IF NOT ERRORLEVEL 1 ECHO %UName% is logged onto %%c))

      ECHO.
      PAUSE
      FOR /L %%v IN (1,1,24) DO ECHO.
      PAUSE
      

:ENDSCRIPT
     EXIT
Try to use PSLOGGEDON from Sysinternals Suite (is freeware and cand be downloaded from www.sysinternals.com)

Just issue at command prompt: PSLOGGEDON UserName and will search for username.
To eliminate "the noise" you could enter the following command: psloggedon -l -x UserName | find "logged"

For details on command line options see: http://technet.microsoft.com/ro-ro/sysinternals/bb897545(en-us).aspx

You will need to have administrative priviledges to access the remote PC's registry - and another "warning" it will take a lot of time to search all your network for PC's and then chech if user is logged on ot not...

Author

Commented:
n/a

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial