Click here to Skip to main content
14,768,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone.
This code below is used to block run certain applications. It works, but to make the effect visible you need to restart the machine.

I would like to do this without having to restart the machine.
How can I do this without a restart?

Is there a possibility of reboot machine without restarting?
Thanks in advance.

What I have tried:

private void blockRunApp()
             Registry.SetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "DisallowRun", 1);

            Microsoft.Win32.RegistryKey rkey;
            rkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\DisallowRun");
            rkey.SetValue("Appname", "App.exe");

Updated 13-Feb-20 23:25pm

1 solution

Is there a possibility of reboot machine without restarting?
No. Rebooting means restarting the whole operating system, or the whole hardware it runs on.
Member 10410972 14-Feb-20 6:18am
OK thanks. Is there another way to block run certain applications using c# ?
OriginalGriff 14-Feb-20 6:45am
No - the problem is that the "don't run list" is read from the registry at startup, not every time you start a process. So no reboot == not known to the OS.

Also be aware that this won't work for everything: it's ignored for Services, and also anything that uses RUNDLL32 to start instead of a "standard EXE" - and that some virus and trojans do exactly that to avoid detection.

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