Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Kill all processes not essential to running Windows

I have an application. If the application is not used in 15 mins it needs to closes all other applications (forced closed) and the timer starts again. I do not want to crash windows 7 doing this. So far I have the following:

Process me = Process.GetCurrentProcess();
foreach (Process p in Process.GetProcesses())
{
    if (p.Id != me.Id 
        && p.ProcessName != "winlogon.exe" 
        && p.ProcessName != "explorer.exe"
        && p.ProcessName != "System Idle Process"
        && p.ProcessName != "taskmgr.exe"
        && p.ProcessName != "spoolsv.exe"
        && p.ProcessName != "csrss.exe"
        && p.ProcessName != "smss.exe"
        && p.ProcessName != "svchost.exe "
        && p.ProcessName != "services.exe"
    )
    {
        p.Kill();
    }
}

Sadly windows dies (blue screen). Is there any way I could close all the processes for the active use then hopefully Windows may survive.

like image 864
Sally Avatar asked Feb 21 '11 22:02

Sally


People also ask

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C language?

C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.

Why do we write C?

It was mainly developed as a system programming language to write an operating system. The main features of the C language include low-level memory access, a simple set of keywords, and a clean style, these features make C language suitable for system programmings like an operating system or compiler development.


1 Answers

First, set up auto-logon on the public PC.

Then, your program just has to reboot.

Bonus points if you set up steady state or use a product like Deep Freeze, System Safe, or Time Freeze. Those products even have an option for rebooting the computer to a clean state after a period of inactivity...

like image 103
Stephen Cleary Avatar answered Sep 23 '22 08:09

Stephen Cleary