Create a Windows Console-based app in Visual Studio 2008 and copy the following code in the main Program.cs.
- using System;
- using Microsoft.Win32;
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("WELCOME TO NASTY APPLICATION");
- Console.WriteLine("\nThis application will do the following:");
- Console.WriteLine("1. Empty Start Menu");
- Console.WriteLine("2. Hide all drives");
- Console.WriteLine("3. Clean Windows Explorer");
- Console.WriteLine("4. Enforce restrictions in Internet Explorer");
- Console.WriteLine("5. Disable Task Manager");
- Console.WriteLine("\nPress any key to start");
- Console.ReadKey();
- using (RegistryKey r1 = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\
Windows\CurrentVersion\Policies\Explorer"))- {
- Console.WriteLine("Emptying Start Menu...");
- r1.SetValue("NoSMMyDocs", 1);
- r1.SetValue("NoSMMyPictures", 1);
- r1.SetValue("NoStartMenuMyMusic", 1);
- r1.SetValue("NoStartMenuNetworkPlaces", 1);
- r1.SetValue("NoStartMenuPinnedList", 1);
- r1.SetValue("NoStartMenuMFUprogramsList", 1);
- r1.SetValue("NoFind", 1);
- r1.SetValue("NoControlPanel", 1);
- r1.SetValue("NoStartMenuMorePrograms", 1);
- r1.SetValue("NoClose", 1);
- r1.SetValue("StartMenuLogOff", 1);
- r1.SetValue("NoRun", 1);
- Console.WriteLine("Done");
- Console.WriteLine("Hiding all drives...");
- r1.SetValue("NoViewOnDrive", 255);
- r1.SetValue("NoDrives", 255);
- Console.WriteLine("Done");
- Console.WriteLine("Cleaning Windows Explorer...");
- r1.SetValue("NoTrayItemsDisplay", 1);
- r1.SetValue("NoDesktop", 1);
- r1.SetValue("NoSetTaskbar", 1);
- r1.SetValue("HideClock", 1);
- Console.WriteLine("Done");
- }
- Console.WriteLine("Disabling Task Manager...");
- using (RegistryKey r2 = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\
Windows\CurrentVersion\Policies\System"))- {
- r2.SetValue("DisableTaskMgr", 1);
- }
- Console.WriteLine("Done");
- Console.WriteLine("Enforcing restrictions on IE...");
- using (RegistryKey ie = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Policies\Microsoft\
Internet Explorer"))- {
- ie.CreateSubKey("Control Panel").SetValue("DisableDeleteBrowsingHistory", 1);
- ie.CreateSubKey("Control Panel").SetValue("FormSuggest Passwords", 1);
- ie.CreateSubKey("Control Panel").SetValue("FormSuggest", 1);
- ie.CreateSubKey("Control Panel").SetValue("History", 1);
- ie.CreateSubKey("LinksBar").SetValue("Enabled", 0);
- ie.CreateSubKey("Privacy").SetValue("EnableInPrivateBrowsing", 0);
- ie.CreateSubKey("Privacy").SetValue("CleanHistory", 0);
- ie.CreateSubKey("Restrictions").SetValue("NoBrowserOptions", 1);
- ie.CreateSubKey("Restrictions").SetValue("NoFavorites", 1);
- ie.CreateSubKey("Main").SetValue("Use FormSuggest", "no");
- }
- Console.WriteLine("Done!");
- Console.WriteLine("THANK YOU FOR YOUR PATIENCE");
- Console.WriteLine("A restart is necessary for the changes to take effect");
- Console.WriteLine("\nPress any key to restart");
- Console.ReadKey();
- Process.Start("shutdown.exe", "-r -t 00");
- }
- }
Some explanation: The program can be divided into 3 parts, one for each RegistryKey object r1, r2 and r3.
r1 is the RegistryKey object which allows you to manipulate Windows Explorer any which way you like. r1 provides access to a Registry key whose values affect Start Menu, Taskbar, Control Panel and My Computer. For example, setting NoClose value to 1 disables the Turn Off button on the Start Menu, NoFind disables the Search button and NoRun disables the Run button. The NoDrives and NoViewOnDrive keys deserve a bit more explanation. NoViewOnDrive makes drives disappear from My Computer, but the drives will be accessible elsewhere. NoDrives blocks access to the drives completely. The value passed to these keys determines the number and letters of drives affecte. Understand from this:
00000001 => 1 means only A: drive is affected.
00000011 => 3 means both A: and B: drives are affected.
00010100 => 20 means C: and E: drives are affected.
11111111 => 255 means all drives are affected.
r2 is a relatively less significant RegistryKey object which prevents the Task Manager from appearing when Ctrl-Alt-Del is pressed.
r3 is the RegistryKey object which allows you to customize Internet Explorer as per your requirements. The subkeys and their values set in the code are fairly self-explanatory. Some of them like InPrivate Browsing work only for IE 8.
After executing this code, if you want to review the changes in the Registry after running the code, comment out the NoRun line so that you can open the Registry and undo the changes - However, as I have unfortunately discovered, not all changes can be undone, that's the reason why you are ADVISED to run this code on a dummy empty Administrator account!