Click here to Skip to main content
15,888,351 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:

C#
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 22:25pm

1 solution

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.
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900