Switching users in Windows 11 via the command line is a quick way to take over another user’s session without logging in manually. This works best when the user is already logged in but needs another account’s session opened immediately—useful for admins or sharing a machine without password prompts. The method requires the target user to be active, and you must be logged in as an account with sufficient privileges (e.g., Administrator). If you’re managing shared computers, this avoids repeated password entries and keeps sessions persistent.

What You'll Need

  • The target Windows 11 user must be currently logged in.
  • Your own Windows 11 PC (must be running the latest updates).
  • Administrative privileges on the PC (local or domain).
  • A command prompt or PowerShell window open (right-click Start > "Terminal" or search for "cmd").

Step-by-Step

  1. Open Command Prompt or PowerShell as Administrator. If you’re not already elevated, right-click the Start button, select "Windows Terminal (Admin)" or "Command Prompt (Admin)".
  2. List all currently logged-in users by running: query user Note the username of the account you want to switch to (e.g., "UserName").
  3. Use the following command to take over the target user’s session. Replace UserName with the actual username from the previous step: logon -u UserName -w This command launches a new window for that user without requiring a password (if they’re logged in).
  4. If the above fails (e.g., the user is locked out), try this alternative syntax: logon -u UserName -n -w The -n flag disables password prompting entirely.
  5. The new session should appear immediately. If it doesn’t, wait 10–30 seconds—the command may need time to initialize the session.

If That Did Not Work

If the command fails with errors like "Logon failure: Unknown user name or bad password" or "Session already exists," try these fixes:
  1. Verify the target user is logged in by checking query user again. If they’re not active, wait for them to log out and then retry.
  2. Ensure your account has admin rights. Run net user in CMD to confirm your account isn’t restricted.
  3. Restart the PC. Sometimes the session service requires a reboot to respond to commands.
  4. If you’re behind a corporate network, check if session control is disabled by IT—a policy may block local switching.

Common Mistakes

  1. Using the wrong username: Double-check the output of query user before pasting the command.
  2. Not running as Admin: Without elevated permissions, the command may fail silently.
  3. Confusing logon with runas: runas prompts for a password, while logon skips it (if the user is active).
  4. Overwriting the wrong session: If multiple users are logged in, logon only takes over the most recent one. Use the full session ID from query session for precision (e.g., logon -s SID).

Tips

  1. Use query session alongside query user to identify the correct session ID for advanced switching: query session | find "State" lists active sessions with IDs (e.g., Session 001). Replace UserName with -s 001 in the logon command.
  2. For multiple users, automate switching by scripting the command in a batch file. Example: @echo off logon -u "Admin" -w Save as switch_admin.bat and run it.
  3. If the user is locked out, use net user to remove their account temporarily (backup data first!) or force a password reset via net user UserName.
  4. Test in a guest session first. Windows 11 may block switching if the target user doesn’t have a proper profile (e.g., from a Microsoft account).

Troubleshooting

  1. Error: "Access Denied." - Confirm your account has admin rights. If it’s a local account, check the "Built-in Administrator" group in Settings > Accounts > Family & other users > Administrators. - If this is a domain PC, your domain credentials may need elevated permissions. Contact IT or use the PC locally to switch.
  2. Error: "User is not logged on." - The user must be actively logged in. If they’re in another session, wait for them to log out or use the session ID method above. - If the user left the PC idle, their session may have terminated. Force a restart if needed (but warn the user).
  3. Command prompts "Nothing happened." - Wait 30 seconds—the session may need time to load. If it still doesn’t appear: - Check Task Manager (Ctrl+Shift+Esc) for lingering processes. - Run sc query winlogon to ensure the logon service is active.
  4. Switching opens a black screen. - This is normal for the first few seconds as the session initializes. Wait for the desktop to load. - If the screen stays black after 2 minutes, the session may be corrupted. Close the original CMD window and retry.
  5. Switching fails after a Windows Update. - The latest updates may restrict local session switching. Reboot the PC and try again.

Frequently Asked Questions

Can I switch users from another computer if they’re on the same network?

No. The command works only when both computers are on the same local network *and* you’re logged in as an admin on the target PC. Remote switching requires RDP (Remote Desktop), which is a separate method. To share a PC remotely, use RDP from another device instead.

Will switching users log the target user out of their own session?

No. The target user’s session remains active. They can continue working while you take over. However, if you close the new session, they’ll lose their unsaved work unless they manually save it first.

How do I switch back to my own session?

Use the same command but with your own username: logon -u YourUsername -w or find your session ID via query session and switch to it (e.g., logon -s YourSessionID).

Can I switch users in Windows 11 without an internet connection?

Yes, but only if the target user has no Microsoft account linked. If they use a Microsoft account, Windows may require an internet connection for session validation. For local accounts, the switch works offline.

Why does Windows 11 sometimes show "Session already exists"?

This happens when you try to open multiple sessions for the same user. The command will ignore subsequent requests until the first session closes. Wait for the target user to log out or end their session manually before retrying.

Is there a way to switch users silently (no GUI interaction)?

Yes, if the target user is logged in, you can use: logon -u UserName -w -g The -g flag forces a graphical session. This doesn’t require a password but still needs the user to be active.