How do I stop a session in CMD?

There are various ways you can close your session on your Windows 10 computer. Some methods are shorter than others, but you choose the one you like best. It may not be the quickest, but it’s what you used to.

But, since saving time is always a good thing, why not look at all your options when it comes to closing your session and choosing the one you want to use at the time. Some users may not use the fastest way because they didn’t know it existed.

1. How to Close a Windows 10 Session Using the Start Menu

When you want to shut down your computer, you click on the Windows start button and click on shut down. But, what if what you want to do is sign out? The sign out option is not found in the power options.

To sign out of your current session, you need to click on the Windows start button, followed by your profile picture. Among the three options, it’ll show you, the Sign Out option will be listed.

2. How to Close a Windows 10 Session Using Advanced Options

The fastest way to access the advanced options is by using pressing the Windows and X keys. When the menu appears, place the cursor over the Shutdown or Sign Out options and click on the Sign Out option.

3. How to Sign Out Using a Keyboard Shortcut

If you’re more of a keyboard shortcut user, there’s a three-key shortcut you can use. By pressing the Ctrl + Alt + Supr keys, you’ll get a blue screen [don’t worry, this blue screen is a good one]. The screen will display various options, and the Sign Out option will be the third one down.

Another keyboard shortcut you can try is Alt + F4. When the window asks you what you want your computer to do, click on the drop-down menu below this message and click on the Sign Out option. Don’t forget to click on the Accept option.

4. How to Sign out with the Command Prompt

If you’re already using the Command Prompt for some other reason, why not sign out from it? The command is short and easy to remember shutdown -L.

Conclusion

Signing out is something you do every day. With the previously mentioned sign out tips, you can choose which one you feel like using at the moment. How do you usually sign out of your computer?

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 -L

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.

logoff /server:remote_computer_name

To logoff on the current system

logoff

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.

By Mikhail Polenin

i Jupiterimages/Goodshoot/Getty Images

Your copy of Windows only allows a certain number of clients to connect via Remote Desktop to your server. Sometimes you actually end up with a “ghost session” from a previous session that didn’t close properly and prevents you from making a new session. To kill this session, you must acquire privileges on the Microsoft server you run remotely and kill the process using the command line.

Go to your "Start" menu and click “Run.”

Write “cmd” and press “Enter” on your keyboard.

Write “net use \server_ip /USER:your_name password.” This logs you in to the remote server without using RDP, or Remote Desktop protocol. Replace “server_ip” with your server’s IP, “your_name” with your user name and “password” with the password you use to log in.

Write “query session /server:name.” Replace “name” with the server’s name. You get the session ID here.

Write “reset session id /server:server_ip,” replacing “server_ip” with the server’s IP. Do not replace anything else, as all the rest is part of the command. This terminates the active session on your remote server. Try connecting now through Remote Desktop to the new server.

Windows 7 / Getting Started

To get to the command prompt, run Cmd.exe, which you can do in any of the following ways:

  • Type cmd in the Start menu search box, and click the Cmd shortcut when it appears, under Programs, at the top of the menu.
  • Press Windows logo key+R, and type cmd in the Open box.
  • Choose Start, All Programs, Accessories, Command Prompt.
  • Double-click the Cmd icon in your %SystemRoot%\System32 folder.
  • Double-click any shortcut for Cmd.exe.

You can open as many Command Prompt windows as you like. With each additional window, you start another Command Prompt session. For example, you might want to open two Command Prompt windows to see two directories in side-by-side windows. To open another Command Prompt window, repeat any of the preceding methods, or type start or start cmd at the command prompt. [These commands produce the same result. If you don't type a program name after typing start, Windows assumes that you want to start Cmd.exe.]

Note Your activities in a Command Prompt session are subject to the same User Account Control [UAC] restrictions as anything else you do in Windows 7. At times, you might find it convenient to start a Command Prompt session with an administrator token; such a session is sometimes called an elevated command prompt. To do this, rightclick any shortcut for Cmd.exe and choose Run As Administrator from the shortcut menu. If you do this as a standard user, you will be prompted to supply administrative credentials.

When the Command Prompt window is active, you can end a Command Prompt session in any of the following ways:

  • Type exit at the command prompt.
  • Click the Close button.
  • Click the Control menu icon, and choose Close.
  • Double-click the Control menu icon.

If you are running a character-based program in the Command Prompt window, you should use the program's normal exit command to quit the program before attempting to close the window and end the Command Prompt session. Otherwise, it's possible that you'll lose unsaved data. However, if you are sure that the program doesn't have any unsaved information, you can safely and quickly close it using one of the last three methods in the preceding list. If a program is running, a dialog box appears asking whether or not you really want to terminate the program.

Windows 7 / Getting Started

Disconnecting a session using the Remote Desktop Services Manager is easy. Find the session to disconnect, right-click it, and choose Disconnect from the context menu. You must be connected to the same server as the session you're disconnecting.

To disconnect a session from the command prompt, use tsdiscon. The syntax is simple.

TSDISCON [sessionid/sessionname] [/SERVER:servername] [/V] Sessionid The ID of the session. Sessionname The name of the session. /SERVER:servername Specifies the RD Session Host server [default is current]. /V Displays information about the actions performed.

As you can see, when using the command-line tool, you can specify the server on which you want to disconnect a session.

CAUTION: If you run tsdiscon without arguments, you'll disconnect your own session even if you're sitting at the console. You won't lose any data because the session will continue running and you can just reconnect, but disconnecting yourself is disconcerting and should be avoided.

Terminating Sessions

You can terminate a session easily from the Remote Desktop Services Manager or the command prompt.

To terminate a session from the Remote Desktop Services Manager, highlight the session on the Users or Sessions tab, right-click, and choose Reset. You'll see a dialog box telling you that you're resetting this user's session. Click OK, and then the session will reset. All processes belonging to that user will be terminated immediately.

You can also terminate active and disconnected sessions from the command line using one of these three utilities [their syntax is shown here].

RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V] RWINSTA {sessionname | sessionid} [/SERVER:servername] [/V] LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]

Reset session and rwinsta are functionally the same in that they terminate the connection ungracefully-the session never has a chance to close open files or save the profile changes. Logoff is a little different in that, although it won't save open files, it will at least write back changes to the profile.

The syntax for all three commands requires that you use the session name or session ID to identify the session you want to close, so you will need to get this information from the Remote Desktop Services Manager or from the command line by using the query user command. The syntax is

QUERY USER [username | sessionname | sessionid] [/SERVER:servername]

For instance, to reset a disconnected session for user marlon.sam on server FUJI, run these commands. The following example checks for Marlon's session after resetting it just to make the point that this session no longer exists.

C:\Users\Administrator>query session marlon.sam /server:FUJI SESSIONNAME USERNAME ID STATE TYPE DEVICE marlon.sam 5 Disc C:\Users\Administrator>reset session 5 /server:FUJI C:\Users\Administrator>query session marlon.sam /server:FUJI No session exists for marlon.sam

[Previous] [Contents] [Next]

Video liên quan

Chủ Đề