Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3219594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:39:51+00:00 2026-05-17T15:39:51+00:00

How can I programatically log off a user remotely (from another machine) with C#?

  • 0

How can I programatically log off a user remotely (from another machine) with C#? All I know is their username. This is done in an Active Directory environment where the account executing this would be an Administrator (Domain Admin). I assume that security would be handled. Would want to avoid having to install an application on the machine.

There does seem to be an API although I do not know what it uses, as “logoff.exe” provided with windows provides for this capability. In the end I can use this, but would prefer to avoid a Process.Start call and relying on it (plus it doesn’t take the username, just the session id).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:39:52+00:00Added an answer on May 17, 2026 at 3:39 pm

    This is more terminal server side of user management but I really like using Cassia


    Another option is do this

    System.Diagnostics.Process.Start("shutdown.exe", String.Format(@"/l /f /m \\{1}", remoteComputerName));
    

    /l is logoff. /f is force. /m \\computername is the name of the remote computer to do the operation on. If you are not on a domain and the user running the app does not have domain admin rights I can not guarantee the above command will work.


    Third option:
    get PsExec then run the shutdown command with it on the remote computer(shutdown.exe /l /f)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I programatically get the path to MSBuild from a machine where my
My goal is to collect all unknown phone numbers from the Call Log. This
I know I can programatically make the taskbar item for a particular window start
If all tables I want to delete from have the column gamer_id can i
in Microsoft Access, is there a way which I can programatically set the Confirm
Can I programatically change the quality of a PDF? I have a client that
How can I programatically cause a control's tooltip to show in a Winforms app
Suppose I create a very simple socket connection, how can one programatically: Find out
How can I retrieve the information shown in the Mac's System Profiler app programatically?
I want to programatically create an NSTextView. How can I determine the correct frame

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.