0

I need to logoff remote users that are on the same domain and I am and admin from a C# .net 4.5 project I am working on. I can successfully do it from the command line (or by opening a subprocess) using:

logoff.exe sessionId /Server:servername

Is there any C# .net (or win32) API to achieve the same result and not need to open subprocesses?

georgeok
  • 5,321
  • 2
  • 39
  • 61
  • you want to logoff from windows ? from a c# program ? did you try running a process (`Process` type) that runs this very logoff.exe the way you do ? – Veverke May 02 '19 at 12:54
  • 2
    [This](https://stackoverflow.com/a/5209603/4137916) seems related (it specifically deals with local users, but the basics are sound for remote ones too). Given all the hoops you have to jump through to call `WTSLogoffSession`, invoking `logoff.exe` may be preferable anyway. – Jeroen Mostert May 02 '19 at 12:55
  • Thanks @Jeroen Mostert. It worked fine at least on Windows 8 that I just tried – georgeok May 02 '19 at 13:06

0 Answers0