About vbscript logoff rdp sessions
I have problems with vbscript logoff rdp sessions. I want to log off user and disable access to a published application that is in the software. How can I do this?
I have problems with vbscript logoff rdp sessions. I want to log off user and disable access to a published application that is in the software. How can I do this?
To log off a user from his or her workstation, you need to be an administrator. You can use some DOS commands to forcibly log off a user from the computer. First of all, you need to know first which terminals are still being used by users. The quser command can be used to query for the sessions that are still running on a specific workstation. The correct syntax for the command is:
Where “quser<space>/<server>:<ServerName>”. Here is a sample screenshot of the command when it is run against a remote machine.
The next problem would be is how you would be able to log off a user from that specific terminal. There is a command called logoff that can be used to forcibly log off a user from his or her workstation based on their session ID. The correct syntax for the command is:
Where “logoff<space><SessionId><space>/<Server>:<ServerName>”. Here is an example screenshot of the command being executed on the command prompt:
To apply these commands on a VBScript, you’ll probably get the script below. Save this script in .vbs format and then run it.
strComputer = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(0)