How can I check who is logged on to a remote computer? On XP I used to run a script called "Whoison.vbs" , but it doesn't seem to work now. How can I gte it to work on windows 7?The tool psloggedon.exe (http://technet.microsoft.com/en-us/sysinternals/bb897545) would tell you. If you wish to use Whoison.vbs then you need to post that script for consideration by respondents.
OK, here is the code:
' WhoLogonInput.vbs
' Sample VBScript to discover which user is logged on
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.4 - December 2005
' -------------------------------------------------------'
Option Explicit
Dim objWMIService, objComputer, colComputer
Dim strLogonUser, strLogonUser1, strComputer
strComputer = "."
strComputer = InputBox("Enter Computer name", "Find Logon User", strComputer)
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
'Note: if objComputer.UserName is null, this generates a
'script error. objComputer.UserName is null when no one is logged in.
strLogonUser = Split(objComputer.UserName,"\")
strLogonUser(1) = UCase(Left(strLogonUser(1),1)) & Trim(Mid(strLogonUser(1),2,20))
Wscript.Echo strLogonUser(1) & " is logged on at " & strComputer
Next
' End of Sample Logged on VBScript
I can't see why your vb Script won't work. It works on my Windows 7 machine. Here is the same thing in Powershell:
$comp = Read-Host 'Enter computer name' Get-WmiObject -Class win32_computersystem -ComputerName $comp | select username
Hi tmccar.
I took the VB Script you posted, and ran it as-is, as a VB Script (using cscript.exe). It gave me the same results as my Powershell version.
In other words, what I'm saying is your VB Script, as you posted it, should work. It does for me. What error do you get?
I'm also saying that if you have Windows 7, you could switch to Powershell, and use the Powershell code I posted to do the same thing as the VB script that you p
OK, thanks. I ran your code within the graphical Powershell window and it worked ok.
Tom
Note that, by default, Win7 has teh management port firewalled. WMI must be opened either manually or via policy.
There is nothing different about Windows 7 to account for your VBScript not working. However, you need to be a member of the local Administrators group. Since the "Domain Admins" group is added to the local Administrators group by default when it is joined to the domain, it should suffice to be a member of "Domain Admins". Also, you might be blocked by a firewall, or WMI could be disabled/blocked on the Windows 7 computer.
For maximum compatibility I commonly specify authenticationLevel when I connect with WMI. For example:
Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ & strComputer & "\root\cimv2")
Just another option:
query session /server:<servername>
You will get something like this:
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
console Boe 1 Active
More info on query.exe
http://technet.microsoft.com/en-us/library/bb490800.aspx
- Edited by Boe ProxMVP, Moderator Friday, January 06, 2012 12:43 AM
- Proposed as answer by Richard MuellerMVP, Moderator Friday, January 06, 2012 2:31 AM
- Marked as answer by Richard MuellerMVP, Moderator Saturday, January 07, 2012 10:40 PM
Is there any vb script which can be used to list logged on user and remotely connected active users? I tried with following WMI query in VB script
1) Select * from Win32_LogonSession Where LogonType = 10
2) Select * from Win32_ComputerSystem
From Win32_ComputerSystem WMI class, I was able to retrieve all
logged on computer users. But I am not able to list remotely logged in users.
Then I tried the first query with LogonType 10. It is not listing values properly.
I am fine to use command line tool Quser.exe. But, if I am using VB script shell
to execute Quser, how can I store the return value from quser to vb variable and
check it? I also do not want command window to appear during this execution.
regards
scomdev
Hi,
I have tried this script and it is working on windows 7 when someone login to machine locally and it is giving error when someone login remotely. Error is same as no one login to remote machine. Does anyone have idea how to fix it? Your help is much appreciated.
I have a windows 7 node which has remote desktop enable. When people login remotely we cant see them. You try to login using Alt+Ctl+Del and enter your credential at that time it will show someone else is on this machine do you want to log them off. At this time you dont know who is logged in. When you press continue then it will show who is logged in but by this time it is too late as user has 30 seconds to respond and the users session will be disconnect if user is not paying attention.
Hi Bigteddy,
I have tried this script and it is working on windows 7 when someone login to machine locally and it is giving error when someone login remotely. Error is same as no one login to remote machine. Does anyone have idea how to fix it? Your help is much appreciated.
I have a windows 7 node which has remote desktop enable. When people login remotely we cant see them. You try to login using Alt+Ctl+Del and enter your credential at that time it will show someone else is on this machine do you want to log them off. At this time you dont know who is logged in. When you press continue then it will show who is logged in but by this time it is too late as user has 30 seconds to respond and the users session will be disconnect if user is not paying attention.
This question is already marked answered.
If you still need help, please start a new question. Be as specific as possible: Post a short script that contains enough code to reproduce the problem, and then present your problem details concisely. Also tell any error messages you're getting. (Remember: We can't see your screen.)
Hi Bigteddy and tmccr,<o:p></o:p>
I have tried this script and it is working on windows 7 when someone login to machine locally and it is giving error when someone login remotely. Error is same as no one login to remote machine. Does anyone have idea how to fix it? Your help is much appreciated.<o:p></o:p>
I have a windows 7 node which has remote desktop enable. When people login remotely we cant see them. You try to login using Alt+Ctl+Del and enter your credential at that time it will show someone else is on this machine do you want to log them off. At this time you dont know who is logged in. When you press continue then it will show who is logged in but by this time it is too late as user has 30 seconds to respond and the users session will be disconnect if user is not paying attention.<o:p></o:p>