It is necessary to close all running applications without using windows logff from a C # application

I need to close all open applications in windows while my application closes, how to do it using C #

I am implementing login / logff functions in my application itself, and not in login / logff for windows, so I need to close all applications when I clicked the logo in my application and transferred control to my application after that

+3
source share
3 answers
using System.Diagnostics;

Process [] localAll = Process.GetProcesses();
foreach(Process p in localAll)
{
    p.Kill();
}

But you may have to insert some kind of filter to avoid killing certain processes, because otherwise the machine might get a little upset.

0
source

- . !

using System.Diagnostics;

Parallel.ForEach(Process.GetProcesses(), process => process.Kill());

; , .

0

. , . " " Windows, , , .

, Windows , ( ), ATI Catalyst Control, Synaptics , Logitech , - Bluetooth-, - , Dell Dell. , , , .


Windows LogOut P/Invoke, ? , Windows ... , , , , .

In the worst case scenario, I will try to collect things that were launched by Windows during startup. Statup elements from StartMenu:

C: \ Users \ User_Name \ AppData \ Roaming \ Microsoft \ Windows \ Start \ Programs \ Launch

and items from the registry:

HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Run

Then we move on to the running processes and see which of them really belong to this user, and just stop them.

0
source

Source: https://habr.com/ru/post/1741722/


All Articles