1

how can my .NET application be informed that an application is about to be executed on the system ?

how can I then prevent if I want that application from executing ?

Attilah
  • 17,632
  • 38
  • 139
  • 202

2 Answers2

0

There are probably a couple of ways of doing this. The cleanest way to me is only possible in an environment with Active Directory. You can set group policies that control which applications can run. This approach may not be possible for you, or create a number of administrative headaches.

You may also be able to modify the RestrictRun registry key.

There are many articles showing how the System.Diagnostics namespace can be used to get a list of running processes. Your .NET application only really knows that the application is running when it is in he process list. You may be able to do something to discover when it is 'about' to be executed outside of .NET.

Once you find an application is running you can use System.Diagnostics to terminate a process.

Brian Lyttle
  • 14,558
  • 15
  • 68
  • 104
0

The 'image hijack' approach that Process Explorer uses should work for this. See my answer here for details.

Community
  • 1
  • 1
Luke Quinane
  • 16,447
  • 13
  • 69
  • 88