Retrieve Username of User on Remote Computer
Hey guys, looking for a way to get the username of a user on a remote computer on a network of WinXP machines, anyone know how? :(
Basically my plan is scan my class room to get everyones usernames, and then when I get net send spammed I'll know who it came from. :p
I've had a try of a few examples on here, but I'm not 100% sure if they're what I'm after. :(
http://vbnet.mvps.org/index.html?code/network/
Thanks inadvance. :)
Re: Retrieve Username of User on Remote Computer
Hey there PC :)
This may be a place to start. I use it to load a ComboBox in my NetSend app:
VB Code:
Private Sub Load_Users()
Dim objDomain As Object
Dim objUser As Object
On Error GoTo Err_Handler
Set objDomain = GetObject("WinNT://" & Environ$("USERDNSDOMAIN"))
Set objUser = GetObject(objDomain.Schema)
objDomain.Filter = Array("User")
For Each objUser In objDomain
cboUsers.AddItem objUser.Name
Next
Set objDomain = Nothing
Set objUser = Nothing
Exit Sub
Err_Handler:
If Not (objDomain Is Nothing) Then Set objDomain = Nothing
If Not (objUser Is Nothing) Then Set objUser = Nothing
MsgBox "Description: " & Err.Description & vbCrLf & _
"Number: " & Err.Number, vbInformation + vbOKOnly, App.Title & " - Error"
End Sub
Bruce.
Re: Retrieve Username of User on Remote Computer
Its Robert the Bruce! I haven't seen you in a while! :p
Yeah, that'll come in handy. :)
It seems that I might need to be an adminstrator to get the username of a remote computer. Most of the examples seem to work for my computer, but if I change it to another computer, I get an error. :(
Re: Retrieve Username of User on Remote Computer
This might help steer you in the right direction...not sure where to go with it but
if you go to search:
pick computers
the enter the computer name in the network..it will return the user name
not sure how you could do this in VB
Re: Retrieve Username of User on Remote Computer
Quote:
Obtaining Workstation User Logon Information
That example seems to work, but it returns all users that have logged on for a while it seems, but it seems to list the current user last. :)
Edit: I guess theres a problem though that it won't be able to tell you if someone is logged onto the computer or not. :(
Re: Retrieve Username of User on Remote Computer
Dear Brute Fox,
Why i can't run your code? I get the error : Run-time Error(-2147463168) Automation Error when i tried to compile it. Do i need to add any references?
Re: Retrieve Username of User on Remote Computer
dglienna, did you not see the following in the code you posted?
VB Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2005 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but [HL="#FFFF80"]you may not reproduce
' or publish this code on any web site[/HL],
' online service, or distribute as source
' on any media without express permission.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Re: Retrieve Username of User on Remote Computer
Oops. I have it on my system, but I didn't read the exclusions. This has become a sore point. i tried to link to it the other day, but it was just the same link that PC Madness had in the first post, and the thread was removed. I asked if I should have posted the code, and was told "After I tested it to see if it worked."
It says that I can use it in my own application, so by creating a form and a few controls makes it my own.
Does that mean that I can post it?
- P C - It's the 5th one on the page.
Re: Retrieve Username of User on Remote Computer
Quote:
Originally Posted by Randy Birch
... or distribute as source
' on any media without express permission.
No you cant without permission.
Best thing to do is to link to the page I suppose?
Re: Retrieve Username of User on Remote Computer
I tried that yesterday, and was blasted because it was the same link that PC posted when he started the thread. I clicked the link that was five links down on the posted page, and the link was the same! Now I posted it and was blasted again.
Re: Retrieve Username of User on Remote Computer
Quote:
Originally Posted by laisengchew
Dear Brute Fox,
Why i can't run your code? I get the error : Run-time Error(-2147463168) Automation Error when i tried to compile it. Do i need to add any references?
Nope. What OS are u using?
Bruce.
Re: Retrieve Username of User on Remote Computer
Well I am late getting into this one but if its a duplicate link then there is no point posting it.
If you find something else thats worthy then post it if its legal. ;)
Re: Retrieve Username of User on Remote Computer
He obviously linked to the page that had all of the links, but no particular program, and I tried to link to a link that was linked to. The page that I tried to link to HAD the code that I then tried to post on it.
IT IS THE FIFTH LINK ON THE PAGE.
Re: Retrieve Username of User on Remote Computer
Chill, David. You dont have to yell! I know its the fifth link on the page. I was referring to you posting a different link that
points to a different article or code sniplette. There is no point in posting a direct link to the same on in the original
first post.
Re: Retrieve Username of User on Remote Computer
My point is that I didn't realize it pointed to the first page and not the second.
There is no way to link to the correct page. That's why I yelled. Not to you, but to PC Madness, so he can find it.
Re: Retrieve Username of User on Remote Computer
Regardless, its not that hard to say PC_Madness, look at the 5th link on that page? You did it on an earlier post.
I dont appreciate yelling, no matter who its directed at.
This is what you should have done - Enumerating the User List and Obtaining User Info
Re: Retrieve Username of User on Remote Computer
That's what I thought that I was doing. I keep forgetting the I have a copy link in Fx. That is the solution. Sorry about losing my cool. It's just been hard helping this time. ;)