Click here to Skip to main content
14,454,989 members
Rate this:
Please Sign up or sign in to vote.
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()
        {
            try
            {
             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");
            rkey.Close();
            }
            catch
            {

            }
        }
Posted
Updated 13-Feb-20 23:25pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Quote:
Is there a possibility of reboot machine without restarting?
No. Rebooting means restarting the whole operating system, or the whole hardware it runs on.
   
Comments
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100