Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Stop An Application From Opening

Tags:

c++

c#

.net

winapi

I want to write a small app that sits in my tray and that allows me to select an executable and prevent it from opening.

The UI of the app is easy to do using WinForms.

What I want to know is how to detect if a certain exe has been lauched and then how to stop it from running. I'm pretty sure I'll have to dig down into some Win32 stuff but I have no experience in that area, hence this post.

There is an existing app similar to this, but I can't for the life of me remember what it's called. It was written in VB6 and it's open source too.

Any help is much appreciated.

like image 667
Spidey Avatar asked Aug 16 '09 16:08

Spidey


People also ask

Can you prevent an app from opening?

Disable Startup Apps in Windows Settings Go to Settings > Apps > Startup to view a list of all apps that can start up automatically and determine which should be disabled. You can sort the list by name, status, or startup impact.

Why do some apps automatically open?

Apps you install on Windows 10 can sometimes configure themselves to run automatically on startup, and they can also configure background services that start every time you boot your computer.


1 Answers

Rather than trying to kill the process when it runs, how about stopping it from running in the first place?

Changing what happens when the shell tries to launch an application is simple - add a new registry key to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

To test this I added a registry key called notepad.exe and within this the string value Debugger with the value calc.exe. Now whenever I try and run notepad calc opens. The following is the exported registry key.

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]
"Debugger"="calc.exe"

Having made this change I've not yet managed to open notepad, not bad for a no code solution. If you need to be 100% certain that the application never runs you could always add a "kill" solution too as detailed by others.

like image 51
Stephen Nutt Avatar answered Oct 19 '22 05:10

Stephen Nutt