John Isaiah Carmona
John Isaiah Carmona

Reputation: 5356

Prevent Force Killing of Application Process

I have a very critical process that will run on the background in my winform application.

How can I prevent the user to end my winform application process?

I want to prevent the user to:

My code is in C#, framework 4, build in VS2010 Pro.

Thanks in advance.

Upvotes: 0

Views: 1721

Answers (3)

Steve
Steve

Reputation: 216303

Stating your 'absolute' need to keep this process running, I really suggest to separate the critical part of your process from your winforms application and to move this part away from the user machine to a company server.
On this server write a service which keeps your vital work alive and running all the time you like.
These kind of 'absolute' requirements could be enforced only on server machines with redundancy disks, ups units and, (especially), informed sysadmins.

Upvotes: 2

linkerro
linkerro

Reputation: 5458

It's basically impossible to stop users from killing processes (you can even kill explorer.exe which is the shell for windows).

So it's recommended that you write your applications in such a way that they are resilient to user action or crashing. In your case it would be wise to have resumable operations in that process.

Upvotes: 2

Ed Bayiates
Ed Bayiates

Reputation: 11220

You can't absolutely ensure these things, but you can get some of what you want by:

1) Run only on Vista or later versions of Windows that assign security levels to processes

2) Run your process as administrator so it is the highest security level.

3) Make sure UAC (User Account Control) is turned on.

4) Turn off access to task manager for the logged in user account (via group policy)

5) Provide no way for the logged in user to elevate to admin, so that he can't run anything that has the privileges to stop your process.

6) Use a Shutdown script to check for your process running and prevent shutdown.

Upvotes: 1

Related Questions