Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

logged in Username of remote machine

Status
Not open for further replies.
Aug 19, 2011
1
GB
Hi there,
I have a little problem!
I have an asset DB that i use to administrate users/machine on our domain.
as SysAdmin i sometimes need to force a reboot on machines which is all fine and dandy, but the other day, i accidentally forced the reboot of a machine which was being used by a user and she REALLY wasnt too impressed (lol).
to prevent this, i need a little msgbox yes/no to confirm the user of the machine before it actually reboots.
something like
"Are you sure you want to reboot " & MachineName & " while the user " & UserName & " is logged in??"

there is a nice little feature to get the username of your local machine:

UserNameWindows = Environ("USERNAME")
MsgBox (UserNameWindows)

But i need to be able to specify a remote machine Name/IP instead?!?!

Any ideas?!!

Charrrs,
JV
 
I build an db just like that and then some! Here is my function:

Function getLoggedOn(sComputer)
On Error Resume Next
counter = 0
If sComputer <> "" Then
If ping(sComputer) = True Then
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set objClass = objWMIService.Get(system)
Set colComputer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
s = ""
For Each objComputer In colComputer
s = objComputer.username
Next
getLoggedOn = s
End If
End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top