- Windows : logoff from command line
- logoff logoff
- Синтаксис Syntax
- Параметры Parameters
- Комментарии Remarks
- Примеры Examples
- Log Off Another User in Windows 10
- To Log Off Another User in Windows 10,
- Log Off Another User from the Command Prompt
- Log Off Another User from with PowerShell
- About Sergey Tkachenko
- 1 thought on “ Log Off Another User in Windows 10 ”
- Automatically log off idle users in Windows
- Non-recommended solutions ^
- Computer-side Group Policy settings ^
- User-side Group Policy settings ^
- logoff
- Syntax
- Parameters
- Remarks
- Examples
Windows : logoff from command line
We can logoff a user session by clicking on the Logoff button in the start menu. We can logoff from command prompt(CMD) too using shutdown command. You need to run the below command.
Shutdown is a Windows in-built command. We don’t have to install it separately. Note that we can run this command from windows Run window also. This command works on all windows editions. (XP, Vista, Server 2k3/2k8, Windows 7)
There’s another command Logoff which also serves the same purpose. This command can be used to logoff sessions on the remote computers also. Find syntax below for this.
To logoff on the current system
This does not accept user name and passwords so it uses the credentials of the current logged in user on the host system.
How to force logoff without waiting for user confirmation to terminate the running applications?
The above commands do forced logoffs.В They kill all the applications one by one and at the end logs off the user.
If I want to login from command line, how do I set it up?
Open Task manager, click on Users, Right Click, manage user account, it will open control panel. It the path above, open cmd from here. shutdown -l to log out.
Login again. It works.
need to logoff but cannot
i need to log out from anther user with the user name
sameing like that…
logoff username:moss /server:172.19.19.50
logoff logoff
Область применения: Windows Server (половина ежегодного канала), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012 Applies to: Windows Server (Semi-Annual Channel), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012
Выполнит выход пользователя из сеанса на удаленный рабочий стол сервере узла сеансов и удалит сеанс. Logs off a user from a session on a Remote Desktop Session Host server and deletes the session.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
Указывает имя сеанса. Specifies the name of the session. Это должен быть активный сеанс. This must be an active session. | |
Указывает числовой идентификатор, определяющий сеанс на сервере. Specifies the numeric ID which identifies the session to the server. | |
/server: /server: | Указывает сервер узла сеансов удаленный рабочий стол, содержащий сеанс, для которого пользователь должен выйти из системы. Specifies the Remote Desktop Session Host server that contains the session whose user you want to log off. Если не указано, используется сервер, на котором активна в данный момент. If unspecified, the server on which you are currently active is used. |
/v /v | Отображает сведения о выполняемых действиях. Displays information about the actions being performed. |
/? /? | Отображение справки в командной строке. Displays help at the command prompt. |
Комментарии Remarks
Вы всегда можете выйти из сеанса, к которому в данный момент выполнен вход. You can always log off yourself from the session to which you are currently logged on. Однако необходимо иметь разрешение « полный доступ» для выхода пользователей из других сеансов. You must, however, have Full Control permission to log off users from other sessions.
Выход пользователя из сеанса без предупреждения может привести к утрате данных в сеансе пользователя. Logging off a user from a session without warning can result in loss of data at the user’s session. Необходимо отправить пользователю сообщение с помощью команды MSG , чтобы предупредить пользователя перед выполнением этого действия. You should send a message to the user by using the msg command to warn the user before taking this action.
Если параметр или не указан, функция выхода из системы выполняет выход пользователя из текущего сеанса. If or isn’t specified, logoff logs the user off from the current session.
После выхода пользователя из системы все процессы завершаются, а сеанс удаляется с сервера. After you log off a user, all processes end and the session is deleted from the server.
Пользователь не может выйти из сеанса консоли. You can’t log off a user from the console session.
Примеры Examples
Для выхода пользователя из текущего сеанса введите: To log off a user from the current session, type:
Для выхода пользователя из сеанса с помощью идентификатора сеанса, например сеанса 12, введите: To log off a user from a session by using the session’s ID, for example session 12, type:
Для выхода пользователя из сеанса с использованием имени сеанса и сервера, например Session TERM04 на сервере Server1, введите: To log off a user from a session by using the name of the session and server, for example session TERM04 on Server1, type:
Log Off Another User in Windows 10
How to Log Off Another User in Windows 10
Although the concept of multiple users sharing one device or one PC is getting rarer by the day, there are still cases when you have to share PCs and switch users fast. Sometimes you need to end a session for another user signed in to your computer. Here are a number of methods you can use.
The situation can be different when you need to end a user session. For example, someone just forgot to sign out from his or her user account, and left running apps and opened docs, so the remain in your computer’s memory and consume its system resources. In this case, it could be useful to kick out the inactive session for the other user.
There are no third party tools required. This can be done using either Task Manager, Command Prompt or PowerShell.
To Log Off Another User in Windows 10,
- Open the Task Manager app.
- If it looks as follows, switch it to the full view using the «More details» link in the bottom right corner.
- Click on the Users tab.
- Right-click on a user account you want to log off.
- Select Sign off from the context menu.
Alternatively, there are a couple of console tools we can use for the same purpose. Let’s review them.
Log Off Another User from the Command Prompt
- Open an elevated command prompt.
- Type or copy-paste the following command: query session . This will list available user sessions.
- Note the ID column value for the user you want to sign off.
- Now, execute the command logoff . For example, logoff 1 .
Finally, you can use PowerShell, as follows.
Log Off Another User from with PowerShell
- Open PowerShell as Administrator.Tip: You can add «Open PowerShell As Administrator» context menu.
- Type or copy-paste the following command: $sessionID = ((quser /server:’you computer name’ | Where-Object < $_ -match 'user name to sign off' >) -split ‘ +’)[2]
- Now, execute the command logoff $sessionID .
The PowerShell method is great when you know the exact user name. You can save it as a script and sign out other users with one click when needed.
Related blog posts:
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
Share this post
About Sergey Tkachenko
Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.
1 thought on “ Log Off Another User in Windows 10 ”
To note, the logoff command is not available on Windows 10 Home editions.
Automatically log off idle users in Windows
- Managing shared mailboxes in Office 365 with PowerShell — Thu, May 5 2016
- Managing shared mailboxes in Office 365 with the GUI — Wed, May 4 2016
- Installing and configuring the Enhanced Mitigation Experience Toolkit (EMET) — Wed, Mar 16 2016
Shared computer systems in areas such as reception desks, computer labs, and call centers can be brought to their knees very quickly if users lock the workstation and walk away when their shift ends. The next person sits down, clicks Switch User, logs in, and repeats the process all over. After enough users, there are enough random applications running in the background to slow the system to a crawl. So, how do you log off the idle sessions? Actually, it’s pretty easy with a free utility and a little Group Policy!
Non-recommended solutions ^
Before we get started, I’d like to address two of the ways I’ve seen suggested as a way to handle logging off idle user sessions. One solution that used to be popular is the winexit.scr screensaver included in the Windows NT Server 4.0 Resource Kit. A systems administrator can set the workstation’s screensaver to winexit.scr, and the user would be logged off when the screensaver activated.
This solution doesn’t take into account newer operating systems that include Fast User Switching. It also requires you to lengthen your screensaver activation time so you don’t accidentally log off a user who has gone on a break or lunch period. And, last but not least, getting this old utility to work correctly on newer OSs is just a pain. Do you really want to run something this old on your network if you don’t have to? Another is a Group Policy setting that a lot of people point to as a solution to this problem. The setting is located in Computer Configuration > Policies > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits > Set time limit for disconnected sessions.
“Set time limit for disconnected sessions” policy (for RDS sessions only)
I’ve seen this setting recommended—a LOT—as a solution for logging off idle users. You can use it for logging off idle users on Remote Desktop Services (RDS, formerly Terminal Services). This session doesn’t work for physical computers that people are using at the console.
Computer-side Group Policy settings ^
To set up our solution, we’ll need to create a new Group Policy Object (GPO) in the Group Policy Management Console (GPMC). For multiuser computers, I usually like to create a new sub-Organizational Unit (OU) inside the original OU that contains all the other non-multiuser computers. This lets the multiuser computers get the same Group Policy as all of the other computers without forcing the “idle logoff” on every single computer.
Create new GPO in the Group Policy Management Console
Next, we’ll need to right-click the new GPO and choose Edit. Once you’re in the Group Policy Management Editor, you’ll need to go to Computer Configuration > Policies > Administrative Templates > System > Group Policy > Configure user Group Policy loopback processing mode. Enable the policy and set it to Merge. This will let us apply a user-side policy to computer objects in Active Directory. (I’ve written articles on loopback processing in Group Policy and common usage scenarios if you’d like more information.)
Configure user Group Policy loopback processing mode to Merge
Next, we’ll need to copy a small utility to the multiuser computers. Go and download idlelogoff.exe.
UPDATE: We removed the link to the website that hosts idlelogoff.exe is because the site is infected with malware. See comments below.
For demo purposes in this article, I’m going to put my copy into Active Directory’s Sysvol folder. For a production environment, you’ll probably want to do this from a file share. Just make sure that domain computers have at least read-only access to both the share and the file system.
IdleLogoff executable in the Sysvol folder
Go back to your GPO and go to Computer Configuration > Preferences > Windows Settings > Files. Right-click Files and choose New > File. In the Source File(s) section, select the IdleLogoff.exe that we put into \\domain.local\sysvol\domain.local\files\IdleLogoff\IdleLogoff.exe. Set the Destination File value to C:\Program Files\IdleLogoff\IdleLogoff.exe.
New File Properties to copy IdleLogoff.exe to computers
User-side Group Policy settings ^
Next, we’ll need to set our user-side Group Policy settings. Go to User Configuration > Policies > Windows Settings > Scripts (Logon/Logoff). Double-click Logon on the right side of the window.
Logon/Logoff scripts in the Group Policy Management Editor
Click the Show Files button to open a new window where you can place the Logon script we’ll use.
Create a new batch file for a Logon script
logoff
Applies to: Windows Server (Semi-Annual Channel), Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012
Logs off a user from a session on a Remote Desktop Session Host server and deletes the session.
Syntax
Parameters
Parameter | Description |
---|---|
Specifies the name of the session. This must be an active session. | |
Specifies the numeric ID which identifies the session to the server. | |
/server: | Specifies the Remote Desktop Session Host server that contains the session whose user you want to log off. If unspecified, the server on which you are currently active is used. |
/v | Displays information about the actions being performed. |
/? | Displays help at the command prompt. |
Remarks
You can always log off yourself from the session to which you are currently logged on. You must, however, have Full Control permission to log off users from other sessions.
Logging off a user from a session without warning can result in loss of data at the user’s session. You should send a message to the user by using the msg command to warn the user before taking this action.
If or isn’t specified, logoff logs the user off from the current session.
After you log off a user, all processes end and the session is deleted from the server.
You can’t log off a user from the console session.
Examples
To log off a user from the current session, type:
To log off a user from a session by using the session’s ID, for example session 12, type:
To log off a user from a session by using the name of the session and server, for example session TERM04 on Server1, type: