Question

How do I disconnect a Remote Desktop session programmatically in a C# or C++ application?

Was it helpful?

Solution

OTHER TIPS

You could try running tsdiscon: http://support.microsoft.com/kb/321705

You can use the following code in C# to fetch the remote desktop connection pid by using its name and then kill

   Process[] my = Process.GetProcessesByName("mstsc");
   int pid = my[0].Id;
   Process pro = Process.GetProcessById(pid);
   pro.Kill();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top