Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Get users name from computer name?

Thread Tools
 
Search this Thread
 
Old 05 March 2007, 03:37 PM
  #1  
bioforger
Scooby Regular
Thread Starter
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Question Get users name from computer name?

As above is it possible?

I can get the users ID on our network, using nbtstat -a computername.

But I need the users real name, any help appreciated thanks.
Old 05 March 2007, 07:54 PM
  #2  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

try this

Code:
' ***********************************************************************************************
' RetrieveLoggedOnUsers.vbs - DWallis 05/03/07
'
' Usage Cscript //NoLogo RetrieveLoggedOnUsers.Vbs computer1Name Computer2Name
' ***********************************************************************************************
 
' ***********************************************************************************************
' Check Script is being run with CSCRIPT
' ***********************************************************************************************
    
If UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" Then
    strPath = Wscript.ScriptFullName
	Wscript.Echo "This script should be run under CScript." & vbCrLf & vbCrLf & "Re-Starting Under CScript"
    strCommand = "%comspec% /K cscript //NOLOGO " & Chr(34) & strPath & chr(34)
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run(strCommand)
    Wscript.Quit
End If

' ***********************************************************************************************
' Check Arguments Passed (Computer Names), If none are passed then default to local machine
' ***********************************************************************************************

If Wscript.Arguments.Count = 0 Then
    arrComputers = Array(".")
Else
    Dim arrComputers()
    For i = 0 to Wscript.Arguments.Count - 1
        Redim Preserve arrComputers(i)
        arrComputers(i) = Wscript.Arguments(i)
    Next
End If
 
For Each strComputer in arrComputers
	Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
	Set colComputers = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
 
	For Each objComputer in colComputers
    		Wscript.Echo "ComputerName: " & strComputer & " UserName: " & objComputer.UserName
	Next
Next
Old 05 March 2007, 07:55 PM
  #3  
jowl
Scooby Regular
 
jowl's Avatar
 
Join Date: Aug 2004
Posts: 1,882
Likes: 0
Received 0 Likes on 0 Posts
Default

I just use Kix

Would that be any could
Old 05 March 2007, 08:10 PM
  #4  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

Kix is just a scripting language, you would still need to query the remote machine to find the users that have an explorer.exe process running or using wmi as I did..

I can also use kix if you want it writing in that, but that involves a download, where as cscript / wscript shouldnt.

David
Old 05 March 2007, 10:57 PM
  #5  
bioforger
Scooby Regular
Thread Starter
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Default

That looks awesome Dave, but as I'm a complete coding noob, how do I run it?

Just save it as a .vbs and run it? Or something (cscript) else? Thanks.
Old 06 March 2007, 11:53 AM
  #6  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

save it as a vbs file, for example RetrieveLoggedOnUsers.Vbs

Then in a command prompt do:

Cscript //NoLogo RetrieveLoggedOnUsers.Vbs computerName AnotherComputer Name


You can pass either one computer name or multiple computernames.

You will need admin rights on the remote pc though.

David
Old 06 March 2007, 11:57 AM
  #7  
mike1210
Scooby Regular
 
mike1210's Avatar
 
Join Date: Apr 2004
Location: Cardiff
Posts: 1,928
Likes: 0
Received 0 Likes on 0 Posts
Default

Ace, works a treat
Old 06 March 2007, 06:44 PM
  #8  
jowl
Scooby Regular
 
jowl's Avatar
 
Join Date: Aug 2004
Posts: 1,882
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by David_Wallis
Kix is just a scripting language, you would still need to query the remote machine to find the users that have an explorer.exe process running or using wmi as I did..

I can also use kix if you want it writing in that, but that involves a download, where as cscript / wscript shouldnt.

David
Ah, sorry didn't read the original question correctly!
Old 06 March 2007, 08:39 PM
  #9  
bioforger
Scooby Regular
Thread Starter
iTrader: (1)
 
bioforger's Avatar
 
Join Date: Jan 2002
Location: Pig Hill, Wiltsh1te
Posts: 16,995
Received 5 Likes on 5 Posts
Smile

Originally Posted by David_Wallis
save it as a vbs file, for example RetrieveLoggedOnUsers.Vbs

Then in a command prompt do:

Cscript //NoLogo RetrieveLoggedOnUsers.Vbs computerName AnotherComputer Name


You can pass either one computer name or multiple computernames.

You will need admin rights on the remote pc though.

David
DOH! completely missed the usage line.

It works a treat thanks alot Dave
Old 06 March 2007, 08:52 PM
  #10  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

No probs.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM
Pro-Line Motorsport
Car Parts For Sale
2
29 September 2015 07:36 PM
shorty87
Wheels And Tyres For Sale
0
29 September 2015 02:18 PM
madmover
Member's Gallery
4
28 September 2015 10:46 AM
shorty87
Other Marques
0
25 September 2015 08:52 PM



Quick Reply: Get users name from computer name?



All times are GMT +1. The time now is 09:49 PM.