Tutorial :C# - Programmatically Log-off and Log-on a user


I'd like to know if is there any way in C# to programatically log-in a Windows User Account?

We are currently developing an monitoring application and one of the feature is to be able to log-off the current Windows User and switch to another Windows User Account.

I have some few methods for Logging off, such as through API or Command Line. But what about logging-in a user account?


You mean interactive?

  • Logoff, if anything fails, spawn a request to logoff.exe
  • Logon - nope. that is a GINA module that can go in front (look it up in google), but this is a very tricky beast to do. The security system in windows is pretty well isolated for obvious reasons (i.e. security).

I am not aware of anything you could do in C#.


has some more details how user logon works.


This might be what you're looking for...codesample

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »