Get users name from computer name?
#2
Scooby Regular
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
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
#4
Scooby Regular
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
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
I can also use kix if you want it writing in that, but that involves a download, where as cscript / wscript shouldnt.
David
#6
Scooby Regular
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
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
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
Trending Topics
#8
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
I can also use kix if you want it writing in that, but that involves a download, where as cscript / wscript shouldnt.
David
#9
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
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
It works a treat thanks alot Dave
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