Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Im making a simple application to close all apps. But I knew if I did this:

C#
Process self = Process.GetCurrentProcess();
foreach (Process p in Process.GetProcesses().Where(p => p.Id != self.Id ))
{
    p.kill            
}


it would even kill windows background apps which would BSOD the OS.

What I have tried:

I didnt try anything since nothing came up in my mind on how to do it.
Does anyone know how to do it?


Thanks
Posted
Updated 11-Aug-21 21:34pm
v2

1 solution

Simple: Don't.

It's up to the user to decide which applications are running on their computer. An application which terminates all other applications on the computer is known as malware.

If it's your computer, then you can use group policy to restrict which applications can run. If it's not your computer, then leave the other applications alone.
 
Share this answer
 
Comments
Member 15321181 12-Aug-21 4:34am    
Oh, I didnt know my application would be malware, Sorry.
Richard Deeming 12-Aug-21 4:37am    
If you downloaded an application from the internet which, when you ran it, killed every other application running on your computer, would you think that was OK?

The only non-malware use I can think of for something like this is running a PC you control in "kiosk" mode. But as I said, you can use Group Policy to enable that, without resorting to dangerous options like terminating other processes.
BillWoodruff 12-Aug-21 15:44pm    
+5 Amen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900