├── wenpcfg.zip ├── wenpcfg ├── WindowsController.cs ├── docs │ ├── wenpcfg-Readme.docx │ ├── wenpcfg-Readme.pdf │ └── wenpcfg-Backgrounder.txt ├── app.config ├── app.manifest ├── Properties │ └── AssemblyInfo.cs ├── wenpcfg.csproj └── Program.cs ├── .gitattributes ├── wenpcfg.sln └── README.md /wenpcfg.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andif888/wenpcfg/HEAD/wenpcfg.zip -------------------------------------------------------------------------------- /wenpcfg/WindowsController.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andif888/wenpcfg/HEAD/wenpcfg/WindowsController.cs -------------------------------------------------------------------------------- /wenpcfg/docs/wenpcfg-Readme.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andif888/wenpcfg/HEAD/wenpcfg/docs/wenpcfg-Readme.docx -------------------------------------------------------------------------------- /wenpcfg/docs/wenpcfg-Readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andif888/wenpcfg/HEAD/wenpcfg/docs/wenpcfg-Readme.pdf -------------------------------------------------------------------------------- /wenpcfg/docs/wenpcfg-Backgrounder.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andif888/wenpcfg/HEAD/wenpcfg/docs/wenpcfg-Backgrounder.txt -------------------------------------------------------------------------------- /wenpcfg/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /wenpcfg.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wenpcfg", "wenpcfg\wenpcfg.csproj", "{65A99E53-FF31-4CE6-8301-DEBB50FFC3D5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {65A99E53-FF31-4CE6-8301-DEBB50FFC3D5}.Debug|Any CPU.ActiveCfg = Release|Any CPU 15 | {65A99E53-FF31-4CE6-8301-DEBB50FFC3D5}.Debug|Any CPU.Build.0 = Release|Any CPU 16 | {65A99E53-FF31-4CE6-8301-DEBB50FFC3D5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {65A99E53-FF31-4CE6-8301-DEBB50FFC3D5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wenpcfg 2 | Windows Explorer Navigation Pane Configuration 3 | 4 | The Windows Explorer Navigation Pane Configuration Tool (WENPCFG) enables you 5 | to show or hide the following nodes and their sub nodes in the navigation pane of 6 | Windows Explorer and also in the Open- and Save-File-Dialogs introduced in Windows 7, 7 | Windows 8, Windows Server 2008 R2 and Windows Server 2012. 8 | 9 | * Libraries 10 | * Favorites 11 | * Computer 12 | * Network 13 | * Home Group 14 | * User Files 15 | * OneDrive (experimental for Windows 10) 16 | * Quick Access (experimental for Windows 10) 17 | 18 | NOTE: Changing the configuration of Windows 19 | Explorer to show or hide any of the above nodes 20 | affects every user logging on to this computer. 21 | It is not possible to set this per user. It is a 22 | machine based configuration. 23 | 24 | WENPCFG is a command line application and is 25 | only intended for Windows 7, Windows 8, Windows 8.1, Windows 10 and 26 | Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server 10. 27 | 28 | Running WENPCFG requires elevated privileges. 29 | 30 | After applying configuration changes you have to restart 31 | Explorer shell process (not only an explorer window). 32 | Simply logoff and logon your windows session. 33 | 34 | For further details check out [wenpcfg-Readme.pdf](https://github.com/andif888/wenpcfg/blob/master/wenpcfg/docs/wenpcfg-Readme.pdf). 35 | ### Download 36 | To download and use wenpcfg then download [wenpcfg.zip](https://github.com/andif888/wenpcfg/blob/master/wenpcfg.zip) 37 | -------------------------------------------------------------------------------- /wenpcfg/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /wenpcfg/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Windows Explorer Navigation Pane Configuration Tool")] 9 | [assembly: AssemblyDescription("Hides or shows nodes of libraries, favorites, network, computer and homegroup in the navigation pane in windows explorer and also in open- and saveFileDialogs introduced in Windows 7, Windows 8, Server 2008 R2 and Server 2012")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("RIANTO")] 12 | [assembly: AssemblyProduct("Windows Explorer Navigation Pane Configuration Tool")] 13 | [assembly: AssemblyCopyright("Copyright © PRIANTO 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1aa12e79-edd3-4933-af40-9ba3bef43f56")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.3.1.0")] 36 | [assembly: AssemblyFileVersion("1.3.1.0")] 37 | -------------------------------------------------------------------------------- /wenpcfg/wenpcfg.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {65A99E53-FF31-4CE6-8301-DEBB50FFC3D5} 9 | Exe 10 | Properties 11 | Sinn.Wenpcfg 12 | wenpcfg 13 | v4.0 14 | 512 15 | publish\ 16 | true 17 | Disk 18 | false 19 | Foreground 20 | 7 21 | Days 22 | false 23 | false 24 | true 25 | 0 26 | 1.0.0.%2a 27 | false 28 | false 29 | true 30 | Client 31 | 32 | 33 | x86 34 | true 35 | full 36 | false 37 | bin\x86\Debug\ 38 | DEBUG;TRACE 39 | prompt 40 | 4 41 | 42 | 43 | x86 44 | pdbonly 45 | true 46 | bin\x86\Release\ 47 | TRACE 48 | prompt 49 | 4 50 | 51 | 52 | app.manifest 53 | 54 | 55 | true 56 | bin\x64\Debug\ 57 | DEBUG;TRACE 58 | full 59 | x64 60 | bin\Debug\WindowsExplorerNavpaneConfig.exe.CodeAnalysisLog.xml 61 | true 62 | GlobalSuppressions.cs 63 | prompt 64 | MinimumRecommendedRules.ruleset 65 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets 66 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules 67 | 68 | 69 | bin\x64\Release\ 70 | TRACE 71 | true 72 | pdbonly 73 | x64 74 | bin\Release\WindowsExplorerNavpaneConfig.exe.CodeAnalysisLog.xml 75 | true 76 | GlobalSuppressions.cs 77 | prompt 78 | MinimumRecommendedRules.ruleset 79 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets 80 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules 81 | 82 | 83 | true 84 | bin\Debug\ 85 | DEBUG;TRACE 86 | full 87 | AnyCPU 88 | bin\Debug\WindowsExplorerNavpaneConfig.exe.CodeAnalysisLog.xml 89 | true 90 | GlobalSuppressions.cs 91 | prompt 92 | MinimumRecommendedRules.ruleset 93 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets 94 | true 95 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules 96 | true 97 | 98 | 99 | bin\Release\ 100 | TRACE 101 | true 102 | pdbonly 103 | AnyCPU 104 | bin\Release\WindowsExplorerNavpaneConfig.exe.CodeAnalysisLog.xml 105 | true 106 | GlobalSuppressions.cs 107 | prompt 108 | MinimumRecommendedRules.ruleset 109 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets 110 | false 111 | ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules 112 | false 113 | 114 | 115 | true 116 | 117 | 118 | ..\finn.snk 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | False 131 | .NET Framework 3.5 SP1 Client Profile 132 | false 133 | 134 | 135 | False 136 | .NET Framework 3.5 SP1 137 | true 138 | 139 | 140 | False 141 | Windows Installer 3.1 142 | true 143 | 144 | 145 | 146 | 147 | finn.snk 148 | 149 | 150 | 151 | Designer 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 168 | -------------------------------------------------------------------------------- /wenpcfg/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | using System.Diagnostics; 6 | using Microsoft.Win32; 7 | using System.Runtime.InteropServices; 8 | 9 | 10 | namespace Sinn.Wenpcfg 11 | { 12 | class Program 13 | { 14 | private static bool is64bit = false; 15 | 16 | private const string acl_full = "D:PAR(A;CI;KA;;;BA)(A;CIIO;KA;;;CO)(A;CI;KA;;;SY)(A;CI;KR;;;BU)"; 17 | private const string acl_read = "D:PAR(A;CIIO;KA;;;CO)(A;CI;KR;;;SY)(A;CI;KR;;;BA)(A;CI;KR;;;BU)"; 18 | 19 | private const string libraries_hkcr = @"CLASSES_ROOT\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}\ShellFolder"; 20 | private const string libraries_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}\ShellFolder"; 21 | private const string libraries_hklm = @"SOFTWARE\Classes\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}\ShellFolder"; 22 | private const string libraries_hklm_classes_syswow64 = @"SOFTWARE\Classes\Wow6432Node\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}\ShellFolder"; 23 | private const string libraries_hklm_syswow64 = @"SOFTWARE\Wow6432Node\Classes\CLSID\{031E4825-7B94-4dc3-B131-E946B44C8DD5}\ShellFolder"; 24 | private const uint libraries_attribute_on = 2961178893; // b080010d 25 | private const uint libraries_attribute_off = 2962227469; // b090010d 26 | 27 | private const string computer_hkcr = @"CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ShellFolder"; 28 | private const string computer_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ShellFolder"; 29 | private const string computer_hklm = @"SOFTWARE\Classes\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ShellFolder"; 30 | private const string computer_hklm_classes_syswow64 = @"SOFTWARE\Classes\Wow6432Node\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ShellFolder"; 31 | private const string computer_hklm_syswow64 = @"SOFTWARE\Wow6432Node\Classes\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\ShellFolder"; 32 | private const uint computer_attribute_on = 0; // DELETE 33 | private const uint computer_attribute_off = 2962489612; //B094010C 34 | 35 | private const string favorites_hkcr = @"CLASSES_ROOT\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder"; 36 | private const string favorites_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder"; 37 | private const string favorites_hklm = @"SOFTWARE\Classes\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder"; 38 | private const string favorites_hklm_classes_syswow64 = @"SOFTWARE\Classes\Wow6432Node\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder"; 39 | private const string favorites_hklm_syswow64 = @"SOFTWARE\Wow6432Node\Classes\CLSID\{323CA680-C24D-4099-B94D-446DD2D7249E}\ShellFolder"; 40 | private const uint favorites_attribute_on = 2693792000; // a0900100 41 | private const uint favorites_attribute_off = 2839544064; // a9400100 42 | 43 | private const string network_hkcr = @"CLASSES_ROOT\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder"; 44 | private const string network_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder"; 45 | private const string network_hklm = @"SOFTWARE\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder"; 46 | private const string network_hklm_classes_syswow64 = @"SOFTWARE\Classes\Wow6432Node\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder"; 47 | private const string network_hklm_syswow64 = @"SOFTWARE\Wow6432Node\Classes\CLSID\{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}\ShellFolder"; 48 | private const uint network_attribute_on = 2953052260; // b0040064 49 | private const uint network_attribute_off = 2962489444; // b0940064 50 | 51 | private const string homegroup_hkcr = @"CLASSES_ROOT\CLSID\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\ShellFolder"; 52 | private const string homegroup_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\ShellFolder"; 53 | private const string homegroup_hklm = @"SOFTWARE\Classes\CLSID\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\ShellFolder"; 54 | private const string homegroup_hklm_classes_syswow64 = @"SOFTWARE\Classes\Wow6432Node\CLSID\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\ShellFolder"; 55 | private const string homegroup_hklm_syswow64 = @"SOFTWARE\Wow6432Node\Classes\CLSID\{B4FB3F98-C1EA-428d-A78A-D1F5659CBA93}\ShellFolder"; 56 | private const uint homegroup_attribute_on = 2961441036; // b084010c 57 | private const uint homegroup_attribute_off = 2962489612; // b094010c 58 | 59 | private const string userfiles_hkcr = @"CLASSES_ROOT\CLSID\{59031a47-3f72-44a7-89c5-5595fe6b30ee}\ShellFolder"; 60 | private const string userfiles_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{59031a47-3f72-44a7-89c5-5595fe6b30ee}\ShellFolder"; 61 | private const string userfiles_hkcr_subkey = @"CLSID\{59031a47-3f72-44a7-89c5-5595fe6b30ee}\ShellFolder"; 62 | private const string userfiles_hkcr_syswow64_subkey = @"Wow6432Node\CLSID\{59031a47-3f72-44a7-89c5-5595fe6b30ee}\ShellFolder"; 63 | private const uint userfiles_attribute_on = 4035182893; // f084012d 64 | private const uint userfiles_attribute_off = 4036231469; // f094012d 65 | 66 | 67 | // Windows 10 68 | private const string onedrive_hkcr = @"CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder"; 69 | private const string onedrive_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder"; 70 | private const string onedrive_hkcr_subkey = @"CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder"; 71 | private const string onedrive_hkcr_syswow64_subkey = @"Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}\ShellFolder"; 72 | private const uint onedrive_attribute_on = 4034920525; // f080004d 73 | private const uint onedrive_attribute_off = 4035969101; // f090004d 74 | 75 | private const string quickaccess_hkcr = @"CLASSES_ROOT\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder"; 76 | private const string quickaccess_hkcr_syswow64 = @"CLASSES_ROOT\Wow6432Node\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder"; 77 | private const string quickaccess_hkcr_subkey = @"CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder"; 78 | private const string quickaccess_hkcr_syswow64_subkey = @"Wow6432Node\CLSID\{679f85cb-0220-4080-b29b-5540cc05aab6}\ShellFolder"; 79 | private const uint quickaccess_attribute_on = 2685403136; // a0100000 80 | private const uint quickaccess_attribute_off = 2690646016; // a0600000 81 | 82 | static void Main(string[] args) 83 | { 84 | bool bInvalidOption = false; 85 | bool bHelp = false; 86 | bool bReboot = false; 87 | bool bLogoff = false; 88 | bool bHideLibraries = false; 89 | bool bHideFavorites = false; 90 | bool bHideNetwork = false; 91 | bool bHideComputer = false; 92 | bool bHideHomeGroup = false; 93 | bool bHideUserFiles = false; 94 | bool bHideOneDrive = false; 95 | bool bHideQuickAccess = false; 96 | bool bShowLibraries = false; 97 | bool bShowFavorites = false; 98 | bool bShowNetwork = false; 99 | bool bShowComputer = false; 100 | bool bShowHomeGroup = false; 101 | bool bShowUserFiles = false; 102 | bool bShowOneDrive = false; 103 | bool bShowQuickAccess = false; 104 | 105 | if (args.Length > 0) 106 | { 107 | try 108 | { 109 | foreach (string arg in args) 110 | { 111 | string cmd = arg.ToLower(); 112 | cmd = cmd.Replace("-", ""); 113 | cmd = cmd.Replace("/", ""); 114 | 115 | switch (cmd) 116 | { 117 | case "hidelibraries": 118 | bHideLibraries = true; 119 | Console.WriteLine("Config to hide libraries icon: \tSET"); 120 | break; 121 | 122 | case "hidefavorites": 123 | bHideFavorites = true; 124 | Console.WriteLine("Config to hide favorites icon: \tSET"); 125 | break; 126 | 127 | case "hidenetwork": 128 | bHideNetwork = true; 129 | Console.WriteLine("Config to hide network icon: \tSET"); 130 | break; 131 | 132 | case "hidecomputer": 133 | bHideComputer = true; 134 | Console.WriteLine("Config to hide computer icon: \tSET"); 135 | break; 136 | 137 | case "hidehomegroup": 138 | bHideHomeGroup = true; 139 | Console.WriteLine("Config to hide home group icon: \tSET"); 140 | break; 141 | 142 | case "hideuserfiles": 143 | bHideUserFiles = true; 144 | Console.WriteLine("Config to hide user files icon: \tSET"); 145 | break; 146 | 147 | case "hideonedrive": 148 | bHideOneDrive = true; 149 | Console.WriteLine("Config to hide onedrive icon: \tSET"); 150 | break; 151 | 152 | case "hidequickaccess": 153 | bHideQuickAccess = true; 154 | Console.WriteLine("Config to hide quick access icon: \tSET"); 155 | break; 156 | 157 | case "showlibraries": 158 | bShowLibraries = true; 159 | Console.WriteLine("Config to show libraries icon: \tSET"); 160 | break; 161 | 162 | case "showfavorites": 163 | bShowFavorites = true; 164 | Console.WriteLine("Config to show favorites icon: \tSET"); 165 | break; 166 | 167 | case "shownetwork": 168 | bShowNetwork = true; 169 | Console.WriteLine("Config to show network icon: \tSET"); 170 | break; 171 | 172 | case "showcomputer": 173 | bShowComputer = true; 174 | Console.WriteLine("Config to show computer icon: \tSET"); 175 | break; 176 | 177 | case "showhomegroup": 178 | bShowHomeGroup = true; 179 | Console.WriteLine("Config to show home group icon: \tSET"); 180 | break; 181 | 182 | case "showuserfiles": 183 | bShowUserFiles = true; 184 | Console.WriteLine("Config to show user files icon: \tSET"); 185 | break; 186 | 187 | case "showonedrive": 188 | bShowOneDrive = true; 189 | Console.WriteLine("Config to show onedrive icon: \tSET"); 190 | break; 191 | 192 | case "showquickaccess": 193 | bShowQuickAccess = true; 194 | Console.WriteLine("Config to show quick access icon: \tSET"); 195 | break; 196 | 197 | case "reboot": 198 | bReboot = true; 199 | Console.WriteLine("Set to reboot immediately ..."); 200 | break; 201 | 202 | case "logoff": 203 | bLogoff = true; 204 | Console.WriteLine("Set to logoff immediately ..."); 205 | break; 206 | 207 | case "?": 208 | bHelp = true; 209 | break; 210 | case "h": 211 | bHelp = true; 212 | break; 213 | case "help": 214 | bHelp = true; 215 | break; 216 | 217 | default: 218 | bInvalidOption = true; 219 | Console.WriteLine(""); 220 | Console.WriteLine("ERROR: Invalid option: " + arg); 221 | Console.WriteLine(""); 222 | Console.WriteLine("Use /? oder /help to display usage information."); 223 | break; 224 | 225 | } 226 | } 227 | 228 | if (bInvalidOption) 229 | return; 230 | if (bHelp) 231 | { 232 | DisplayHelp(); 233 | return; 234 | } 235 | 236 | 237 | SetOSInfo(); 238 | if (is64bit) 239 | { 240 | Console.WriteLine("Running in 64-bit process..."); 241 | } 242 | else 243 | { 244 | Console.WriteLine("Running in 32-bit process..."); 245 | } 246 | 247 | 248 | 249 | if (bHideLibraries) 250 | { 251 | HideLibraries(); 252 | } 253 | if (bHideFavorites) 254 | { 255 | HideFavorites(); 256 | } 257 | if (bHideNetwork) 258 | { 259 | HideNetwork(); 260 | } 261 | if (bHideComputer) 262 | { 263 | HideComputer(); 264 | } 265 | if (bHideHomeGroup) 266 | { 267 | HideHomeGroup(); 268 | } 269 | if (bHideUserFiles) 270 | { 271 | HideUserFiles(); 272 | } 273 | if (bHideOneDrive) 274 | { 275 | HideOneDrive(); 276 | } 277 | if (bHideQuickAccess) 278 | { 279 | HideQuickAccess(); 280 | } 281 | 282 | if (bShowLibraries) 283 | { 284 | ShowLibraries(); 285 | } 286 | if (bShowFavorites) 287 | { 288 | ShowFavorites(); 289 | } 290 | if (bShowNetwork) 291 | { 292 | ShowNetwork(); 293 | } 294 | if (bShowComputer) 295 | { 296 | ShowComputer(); 297 | } 298 | if (bShowHomeGroup) 299 | { 300 | ShowHomeGroup(); 301 | } 302 | if (bShowUserFiles) 303 | { 304 | ShowUserFiles(); 305 | } 306 | if (bShowOneDrive) 307 | { 308 | ShowOneDrive(); 309 | } 310 | if (bShowQuickAccess) 311 | { 312 | ShowQuickAccess(); 313 | } 314 | 315 | if (bLogoff && !bReboot) 316 | { 317 | LogoffComputer(); 318 | } 319 | 320 | if (bReboot) 321 | { 322 | RebootComputer(); 323 | } 324 | else 325 | { 326 | Console.WriteLine("######################################################################"); 327 | Console.WriteLine("NOTE: In order to changes take effect you have to logoff an re-logon."); 328 | Console.WriteLine("######################################################################"); 329 | } 330 | 331 | 332 | } 333 | catch (Exception ex) 334 | { 335 | Console.WriteLine(ex.ToString()); 336 | } 337 | } 338 | else 339 | { 340 | DisplayHelp(); 341 | } 342 | } 343 | 344 | private static void SetOSInfo() 345 | { 346 | // http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net 347 | 348 | if (IntPtr.Size == 8) 349 | { 350 | is64bit = true; 351 | } 352 | } 353 | 354 | private static void DisplayHelp() 355 | { 356 | Console.WriteLine(""); 357 | Console.WriteLine("Hides or shows the icons of libraries, favorites, network and computer in the navigation pane of Windows Explorer and also in Open- and SaveFileDialogs introduced in Windows 7 and Server 2008 R2."); 358 | Console.WriteLine("After applying configuration changes you have to restart Explorer shell process (not only an explorer window). Simply logoff and logon your windows session."); 359 | 360 | Console.WriteLine(""); 361 | Console.WriteLine("USAGE:"); 362 | Console.WriteLine("\tWENPCFG [option [option] ... ]"); 363 | Console.WriteLine(""); 364 | Console.WriteLine("options:"); 365 | Console.WriteLine("\t/HideLibraries \tHide libraries icon in the navigation pane"); 366 | Console.WriteLine("\t\t\tof Windows Explorer."); 367 | 368 | Console.WriteLine("\t/HideFavorites \tHide favorites icon in the navigation pane"); 369 | Console.WriteLine("\t\t\tof Windows Explorer."); 370 | 371 | Console.WriteLine("\t/HideNetwork \tHide network icon in the navigation pane"); 372 | Console.WriteLine("\t\t\tof Windows Explorer."); 373 | 374 | Console.WriteLine("\t/HideComputer \tHide computer icon in the navigation pane"); 375 | Console.WriteLine("\t\t\tof Windows Explorer."); 376 | 377 | Console.WriteLine("\t/HideHomeGroup \tHide home group icon in the navigation pane"); 378 | Console.WriteLine("\t\t\tof Windows Explorer."); 379 | 380 | Console.WriteLine("\t/HideUserFiles \tHide user files icon in the navigation pane"); 381 | Console.WriteLine("\t\t\tof Windows Explorer."); 382 | 383 | Console.WriteLine("\t/HideOneDrive \tHide OnDrive icon in the navigation pane"); 384 | Console.WriteLine("\t\t\tof Windows Explorer (Experimental for Windows 10)."); 385 | 386 | Console.WriteLine("\t/HideQuickAccess \tHide quick access icon in the navigation pane"); 387 | Console.WriteLine("\t\t\tof Windows Explorer (Experimental for Windows 10)."); 388 | 389 | Console.WriteLine("\t/ShowLibraries \tShow libraries icon in the navigation pane"); 390 | Console.WriteLine("\t\t\tof Windows Explorer."); 391 | 392 | Console.WriteLine("\t/ShowFavorites \tShow favorites icon in the navigation pane"); 393 | Console.WriteLine("\t\t\tof Windows Explorer."); 394 | 395 | Console.WriteLine("\t/ShowNetwork \tShow network icon in the navigation pane"); 396 | Console.WriteLine("\t\t\tof Windows Explorer."); 397 | 398 | Console.WriteLine("\t/ShowComputer \tShow computer icon in the navigation pane"); 399 | Console.WriteLine("\t\t\tof Windows Explorer."); 400 | 401 | Console.WriteLine("\t/ShowHomeGroup \tShow home group icon in the navigation pane"); 402 | Console.WriteLine("\t\t\tof Windows Explorer."); 403 | 404 | Console.WriteLine("\t/ShowUserFiles \tShow user files icon in the navigation pane"); 405 | Console.WriteLine("\t\t\tof Windows Explorer."); 406 | 407 | Console.WriteLine("\t/ShowOneDrive \tShow OneDrive icon in the navigation pane"); 408 | Console.WriteLine("\t\t\tof Windows Explorer (Experimental for Windows 10)."); 409 | 410 | Console.WriteLine("\t/ShowQuickAccess \tShow quick access icon in the navigation pane"); 411 | Console.WriteLine("\t\t\tof Windows Explorer (Experimental for Windows 10)."); 412 | 413 | Console.WriteLine("\t/Logoff \tIn order to changes take effect the explorer"); 414 | Console.WriteLine("\t\t\tshell process needs to be restarted. Specifying this"); 415 | Console.WriteLine("\t\t\toption causes your windows session to logoff immediately."); 416 | 417 | Console.WriteLine("\t/Reboot \tIn order to changes take effect the explorer"); 418 | Console.WriteLine("\t\t\tshell process needs to be restarted. Specifying this"); 419 | Console.WriteLine("\t\t\toption causes the computer to reboot immediately."); 420 | 421 | Console.WriteLine("\t/Help \t\tDisplays this usage information."); 422 | Console.WriteLine(""); 423 | Console.WriteLine("Samples:"); 424 | Console.WriteLine(""); 425 | Console.WriteLine("\tHide libraries and network icon, keep other icons untouched:"); 426 | Console.WriteLine(""); 427 | Console.WriteLine("\t> WENPCFG /HideLibraries /HideNetwork"); 428 | Console.WriteLine(""); 429 | Console.WriteLine("\tShow computer icon, hide network icon and favorites, keep"); 430 | Console.WriteLine("\tlibraries untouched and immediately reboot:"); 431 | Console.WriteLine(""); 432 | Console.WriteLine("\t> WENPCFG /ShowComputer /HideNetwork /HideFavorites /Logoff"); 433 | Console.WriteLine(""); 434 | Console.WriteLine(""); 435 | Console.WriteLine("Author:"); 436 | Console.WriteLine("\tAndreas Fleischmann (andreas.fleischmann@prianto.com)"); 437 | Console.WriteLine(""); 438 | 439 | 440 | } 441 | 442 | private static void HideLibraries() 443 | { 444 | Dictionary regkeyAclFull = new Dictionary(); 445 | Dictionary regkeyAclRead = new Dictionary(); 446 | regkeyAclFull.Add(libraries_hkcr, acl_full); 447 | regkeyAclRead.Add(libraries_hkcr, acl_read); 448 | if (is64bit) 449 | { 450 | regkeyAclFull.Add(libraries_hkcr_syswow64, acl_full); 451 | regkeyAclRead.Add(libraries_hkcr_syswow64, acl_read); 452 | } 453 | ExecSecedit(regkeyAclFull); 454 | SetRegkey(libraries_hklm, libraries_attribute_off); 455 | if (is64bit) 456 | { 457 | SetRegkey(libraries_hklm_classes_syswow64, libraries_attribute_off); 458 | SetRegkey(libraries_hklm_syswow64, libraries_attribute_off); 459 | } 460 | ExecSecedit(regkeyAclRead); 461 | 462 | } 463 | private static void HideFavorites() 464 | { 465 | Dictionary regkeyAclFull = new Dictionary(); 466 | Dictionary regkeyAclRead = new Dictionary(); 467 | regkeyAclFull.Add(favorites_hkcr, acl_full); 468 | regkeyAclRead.Add(favorites_hkcr, acl_read); 469 | if (is64bit) 470 | { 471 | regkeyAclFull.Add(favorites_hkcr_syswow64, acl_full); 472 | regkeyAclRead.Add(favorites_hkcr_syswow64, acl_read); 473 | } 474 | ExecSecedit(regkeyAclFull); 475 | SetRegkey(favorites_hklm, favorites_attribute_off); 476 | if (is64bit) 477 | { 478 | SetRegkey(favorites_hklm_classes_syswow64, favorites_attribute_off); 479 | SetRegkey(favorites_hklm_syswow64, favorites_attribute_off); 480 | } 481 | ExecSecedit(regkeyAclRead); 482 | } 483 | private static void HideNetwork() 484 | { 485 | Dictionary regkeyAclFull = new Dictionary(); 486 | Dictionary regkeyAclRead = new Dictionary(); 487 | regkeyAclFull.Add(network_hkcr, acl_full); 488 | regkeyAclRead.Add(network_hkcr, acl_read); 489 | if (is64bit) 490 | { 491 | regkeyAclFull.Add(network_hkcr_syswow64, acl_full); 492 | regkeyAclRead.Add(network_hkcr_syswow64, acl_read); 493 | } 494 | ExecSecedit(regkeyAclFull); 495 | SetRegkey(network_hklm, network_attribute_off); 496 | if (is64bit) 497 | { 498 | SetRegkey(network_hklm_classes_syswow64, network_attribute_off); 499 | SetRegkey(network_hklm_syswow64, network_attribute_off); 500 | } 501 | ExecSecedit(regkeyAclRead); 502 | } 503 | private static void HideComputer() 504 | { 505 | Dictionary regkeyAclFull = new Dictionary(); 506 | Dictionary regkeyAclRead = new Dictionary(); 507 | regkeyAclFull.Add(computer_hkcr, acl_full); 508 | regkeyAclRead.Add(computer_hkcr, acl_read); 509 | if (is64bit) 510 | { 511 | regkeyAclFull.Add(computer_hkcr_syswow64, acl_full); 512 | regkeyAclRead.Add(computer_hkcr_syswow64, acl_read); 513 | } 514 | ExecSecedit(regkeyAclFull); 515 | SetRegkey(computer_hklm, computer_attribute_off); 516 | if (is64bit) 517 | { 518 | SetRegkey(computer_hklm_classes_syswow64, computer_attribute_off); 519 | SetRegkey(computer_hklm_syswow64, computer_attribute_off); 520 | } 521 | ExecSecedit(regkeyAclRead); 522 | } 523 | private static void HideHomeGroup() 524 | { 525 | Dictionary regkeyAclFull = new Dictionary(); 526 | Dictionary regkeyAclRead = new Dictionary(); 527 | 528 | regkeyAclFull.Add(homegroup_hkcr, acl_full); 529 | regkeyAclRead.Add(homegroup_hkcr, acl_read); 530 | if (is64bit) 531 | { 532 | regkeyAclFull.Add(homegroup_hkcr_syswow64, acl_full); 533 | regkeyAclRead.Add(homegroup_hkcr_syswow64, acl_read); 534 | } 535 | ExecSecedit(regkeyAclFull); 536 | SetRegkey(homegroup_hklm, homegroup_attribute_off); 537 | if (is64bit) 538 | { 539 | SetRegkey(homegroup_hklm_classes_syswow64, homegroup_attribute_off); 540 | SetRegkey(homegroup_hklm_syswow64, homegroup_attribute_off); 541 | } 542 | ExecSecedit(regkeyAclRead); 543 | } 544 | private static void HideUserFiles() 545 | { 546 | Dictionary regkeyAclFull = new Dictionary(); 547 | Dictionary regkeyAclRead = new Dictionary(); 548 | 549 | regkeyAclFull.Add(userfiles_hkcr, acl_full); 550 | regkeyAclRead.Add(userfiles_hkcr, acl_read); 551 | if (is64bit) 552 | { 553 | regkeyAclFull.Add(userfiles_hkcr_syswow64, acl_full); 554 | regkeyAclRead.Add(userfiles_hkcr_syswow64, acl_read); 555 | } 556 | ExecSecedit(regkeyAclFull); 557 | SetRegkeyClassesRoot(userfiles_hkcr_subkey, userfiles_attribute_off); 558 | if (is64bit) 559 | { 560 | SetRegkeyClassesRoot(userfiles_hkcr_syswow64_subkey, userfiles_attribute_off); 561 | } 562 | ExecSecedit(regkeyAclRead); 563 | } 564 | 565 | #region Windows 10 566 | // Windows 10 567 | private static void HideOneDrive() 568 | { 569 | Dictionary regkeyAclFull = new Dictionary(); 570 | Dictionary regkeyAclRead = new Dictionary(); 571 | 572 | regkeyAclFull.Add(onedrive_hkcr, acl_full); 573 | regkeyAclRead.Add(onedrive_hkcr, acl_read); 574 | if (is64bit) 575 | { 576 | regkeyAclFull.Add(onedrive_hkcr_syswow64, acl_full); 577 | regkeyAclRead.Add(onedrive_hkcr_syswow64, acl_read); 578 | } 579 | ExecSecedit(regkeyAclFull); 580 | SetRegkeyClassesRoot(onedrive_hkcr_subkey, onedrive_attribute_off); 581 | if (is64bit) 582 | { 583 | SetRegkeyClassesRoot(onedrive_hkcr_syswow64_subkey, onedrive_attribute_off); 584 | } 585 | ExecSecedit(regkeyAclRead); 586 | } 587 | 588 | private static void HideQuickAccess() 589 | { 590 | Dictionary regkeyAclFull = new Dictionary(); 591 | Dictionary regkeyAclRead = new Dictionary(); 592 | 593 | regkeyAclFull.Add(quickaccess_hkcr, acl_full); 594 | regkeyAclRead.Add(quickaccess_hkcr, acl_read); 595 | if (is64bit) 596 | { 597 | regkeyAclFull.Add(quickaccess_hkcr_syswow64, acl_full); 598 | regkeyAclRead.Add(quickaccess_hkcr_syswow64, acl_read); 599 | } 600 | ExecSecedit(regkeyAclFull); 601 | SetRegkeyClassesRoot(quickaccess_hkcr_subkey, quickaccess_attribute_off); 602 | if (is64bit) 603 | { 604 | SetRegkeyClassesRoot(quickaccess_hkcr_syswow64_subkey, quickaccess_attribute_off); 605 | } 606 | ExecSecedit(regkeyAclRead); 607 | } 608 | 609 | private static void SetExplorerLaunchTo_Computer() 610 | { 611 | RegistryKey usersKey = Registry.Users; 612 | string[] userKeyNames = usersKey.GetSubKeyNames(); 613 | foreach (string userKeyName in userKeyNames) 614 | { 615 | RegistryKey explorerKey = usersKey.OpenSubKey(userKeyName + @"\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true); 616 | 617 | if (explorerKey != null) 618 | { 619 | explorerKey.SetValue("LaunchTo", 1, RegistryValueKind.DWord); 620 | explorerKey.Close(); 621 | } 622 | else 623 | { 624 | Console.WriteLine("Warning: " + userKeyName + " not found."); 625 | } 626 | } 627 | } 628 | #endregion 629 | 630 | 631 | 632 | private static void ShowLibraries() 633 | { 634 | Dictionary regkeyAclFull = new Dictionary(); 635 | Dictionary regkeyAclRead = new Dictionary(); 636 | regkeyAclFull.Add(libraries_hkcr, acl_full); 637 | regkeyAclRead.Add(libraries_hkcr, acl_read); 638 | if (is64bit) 639 | { 640 | regkeyAclFull.Add(libraries_hkcr_syswow64, acl_full); 641 | regkeyAclRead.Add(libraries_hkcr_syswow64, acl_read); 642 | } 643 | ExecSecedit(regkeyAclFull); 644 | SetRegkey(libraries_hklm, libraries_attribute_on); 645 | if (is64bit) 646 | { 647 | SetRegkey(libraries_hklm_classes_syswow64, libraries_attribute_on); 648 | SetRegkey(libraries_hklm_syswow64, libraries_attribute_on); 649 | } 650 | ExecSecedit(regkeyAclRead); 651 | } 652 | private static void ShowFavorites() 653 | { 654 | Dictionary regkeyAclFull = new Dictionary(); 655 | Dictionary regkeyAclRead = new Dictionary(); 656 | regkeyAclFull.Add(favorites_hkcr, acl_full); 657 | regkeyAclRead.Add(favorites_hkcr, acl_read); 658 | if (is64bit) 659 | { 660 | regkeyAclFull.Add(favorites_hkcr_syswow64, acl_full); 661 | regkeyAclRead.Add(favorites_hkcr_syswow64, acl_read); 662 | } 663 | ExecSecedit(regkeyAclFull); 664 | SetRegkey(favorites_hklm, favorites_attribute_on); 665 | if (is64bit) 666 | { 667 | SetRegkey(favorites_hklm_classes_syswow64, favorites_attribute_on); 668 | SetRegkey(favorites_hklm_syswow64, favorites_attribute_on); 669 | } 670 | ExecSecedit(regkeyAclRead); 671 | } 672 | private static void ShowNetwork() 673 | { 674 | Dictionary regkeyAclFull = new Dictionary(); 675 | Dictionary regkeyAclRead = new Dictionary(); 676 | regkeyAclFull.Add(network_hkcr, acl_full); 677 | regkeyAclRead.Add(network_hkcr, acl_read); 678 | if (is64bit) 679 | { 680 | regkeyAclFull.Add(network_hkcr_syswow64, acl_full); 681 | regkeyAclRead.Add(network_hkcr_syswow64, acl_read); 682 | } 683 | ExecSecedit(regkeyAclFull); 684 | SetRegkey(network_hklm, network_attribute_on); 685 | if (is64bit) 686 | { 687 | SetRegkey(network_hklm_classes_syswow64, network_attribute_on); 688 | SetRegkey(network_hklm_syswow64, network_attribute_on); 689 | } 690 | ExecSecedit(regkeyAclRead); 691 | } 692 | private static void ShowComputer() 693 | { 694 | Dictionary regkeyAclFull = new Dictionary(); 695 | Dictionary regkeyAclRead = new Dictionary(); 696 | regkeyAclFull.Add(computer_hkcr, acl_full); 697 | regkeyAclRead.Add(computer_hkcr, acl_read); 698 | if (is64bit) 699 | { 700 | regkeyAclFull.Add(computer_hkcr_syswow64, acl_full); 701 | regkeyAclRead.Add(computer_hkcr_syswow64, acl_read); 702 | } 703 | ExecSecedit(regkeyAclFull); 704 | DeleteRegValue(computer_hklm); 705 | if (is64bit) 706 | { 707 | DeleteRegValue(computer_hklm_classes_syswow64); 708 | DeleteRegValue(computer_hklm_syswow64); 709 | } 710 | ExecSecedit(regkeyAclRead); 711 | } 712 | private static void ShowHomeGroup() 713 | { 714 | Dictionary regkeyAclFull = new Dictionary(); 715 | Dictionary regkeyAclRead = new Dictionary(); 716 | regkeyAclFull.Add(homegroup_hkcr, acl_full); 717 | regkeyAclRead.Add(homegroup_hkcr, acl_read); 718 | if (is64bit) 719 | { 720 | regkeyAclFull.Add(homegroup_hkcr_syswow64, acl_full); 721 | regkeyAclRead.Add(homegroup_hkcr_syswow64, acl_read); 722 | } 723 | ExecSecedit(regkeyAclFull); 724 | SetRegkey(homegroup_hklm, homegroup_attribute_on); 725 | if (is64bit) 726 | { 727 | SetRegkey(homegroup_hklm_classes_syswow64, homegroup_attribute_on); 728 | SetRegkey(homegroup_hklm_syswow64, homegroup_attribute_on); 729 | } 730 | ExecSecedit(regkeyAclRead); 731 | } 732 | private static void ShowUserFiles() 733 | { 734 | Dictionary regkeyAclFull = new Dictionary(); 735 | Dictionary regkeyAclRead = new Dictionary(); 736 | regkeyAclFull.Add(userfiles_hkcr, acl_full); 737 | regkeyAclRead.Add(userfiles_hkcr, acl_read); 738 | if (is64bit) 739 | { 740 | regkeyAclFull.Add(userfiles_hkcr_syswow64, acl_full); 741 | regkeyAclRead.Add(userfiles_hkcr_syswow64, acl_read); 742 | } 743 | ExecSecedit(regkeyAclFull); 744 | SetRegkeyClassesRoot(userfiles_hkcr_subkey, userfiles_attribute_on); 745 | if (is64bit) 746 | { 747 | SetRegkeyClassesRoot(userfiles_hkcr_syswow64_subkey, userfiles_attribute_on); 748 | } 749 | ExecSecedit(regkeyAclRead); 750 | } 751 | 752 | #region Windows 10 753 | private static void ShowOneDrive() 754 | { 755 | Dictionary regkeyAclFull = new Dictionary(); 756 | Dictionary regkeyAclRead = new Dictionary(); 757 | regkeyAclFull.Add(onedrive_hkcr, acl_full); 758 | regkeyAclRead.Add(onedrive_hkcr, acl_read); 759 | if (is64bit) 760 | { 761 | regkeyAclFull.Add(onedrive_hkcr_syswow64, acl_full); 762 | regkeyAclRead.Add(onedrive_hkcr_syswow64, acl_read); 763 | } 764 | ExecSecedit(regkeyAclFull); 765 | SetRegkeyClassesRoot(onedrive_hkcr_subkey, onedrive_attribute_on); 766 | if (is64bit) 767 | { 768 | SetRegkeyClassesRoot(onedrive_hkcr_syswow64_subkey, onedrive_attribute_on); 769 | } 770 | ExecSecedit(regkeyAclRead); 771 | } 772 | private static void ShowQuickAccess() 773 | { 774 | Dictionary regkeyAclFull = new Dictionary(); 775 | Dictionary regkeyAclRead = new Dictionary(); 776 | regkeyAclFull.Add(quickaccess_hkcr, acl_full); 777 | regkeyAclRead.Add(quickaccess_hkcr, acl_read); 778 | if (is64bit) 779 | { 780 | regkeyAclFull.Add(quickaccess_hkcr_syswow64, acl_full); 781 | regkeyAclRead.Add(quickaccess_hkcr_syswow64, acl_read); 782 | } 783 | ExecSecedit(regkeyAclFull); 784 | SetRegkeyClassesRoot(quickaccess_hkcr_subkey, quickaccess_attribute_on); 785 | if (is64bit) 786 | { 787 | SetRegkeyClassesRoot(quickaccess_hkcr_syswow64_subkey, quickaccess_attribute_on); 788 | } 789 | ExecSecedit(regkeyAclRead); 790 | } 791 | #endregion 792 | 793 | private static void ExecSecedit(Dictionary regkeyAclList) 794 | { 795 | StringBuilder sb = new StringBuilder(); 796 | sb.AppendLine("[Unicode]"); 797 | sb.AppendLine("Unicode=yes"); 798 | sb.AppendLine("[Version]"); 799 | sb.AppendLine("signature=\"$CHICAGO$\""); 800 | sb.AppendLine("Revision=1"); 801 | sb.AppendLine("[Registry Keys]"); 802 | 803 | foreach (KeyValuePair kvp in regkeyAclList) 804 | { 805 | string regkey = kvp.Key; 806 | string acl = kvp.Value; 807 | sb.AppendLine("\"" + regkey + "\"" + ",0," + "\"" + acl + "\""); 808 | } 809 | 810 | string infFile = Environment.GetEnvironmentVariable("SystemDrive") + "\\wenc.inf"; 811 | string dummyDb = Environment.GetEnvironmentVariable("SystemDrive") + "\\wenc.db"; 812 | File.WriteAllText(infFile, sb.ToString()); 813 | 814 | 815 | Process seceditProc = new Process(); 816 | seceditProc.StartInfo.FileName = Environment.GetEnvironmentVariable("SystemRoot") + "\\system32\\secedit.exe"; 817 | seceditProc.StartInfo.Arguments = "/CONFIGURE /CFG " + infFile + " /DB " + dummyDb + " /OVERWRITE /AREAS REGKEYS /QUIET"; 818 | seceditProc.Start(); 819 | 820 | seceditProc.WaitForExit(); 821 | seceditProc.Close(); 822 | 823 | File.Delete(infFile); 824 | File.Delete(dummyDb); 825 | 826 | } 827 | 828 | private static void SetRegkey(string subkey, uint attributesValue) 829 | { 830 | RegistryKey shellFolderKey = Registry.LocalMachine.OpenSubKey(subkey, true); 831 | if (shellFolderKey != null) 832 | { 833 | shellFolderKey.SetValue("Attributes", unchecked((int)attributesValue), RegistryValueKind.DWord); 834 | shellFolderKey.Close(); 835 | } 836 | else 837 | { 838 | Console.WriteLine("Warning: " + subkey + " not found."); 839 | } 840 | } 841 | 842 | private static void SetRegkeyClassesRoot(string subkey, uint attributesValue) 843 | { 844 | RegistryKey shellFolderKey = Registry.ClassesRoot.OpenSubKey(subkey, true); 845 | if (shellFolderKey != null) 846 | { 847 | shellFolderKey.SetValue("Attributes", unchecked((int)attributesValue), RegistryValueKind.DWord); 848 | shellFolderKey.Close(); 849 | } 850 | else 851 | { 852 | Console.WriteLine("Warning: " + subkey + " not found."); 853 | } 854 | } 855 | 856 | private static void DeleteRegValue(string subkey) 857 | { 858 | RegistryKey shellFolderKey = Registry.LocalMachine.OpenSubKey(subkey,true); 859 | if (shellFolderKey != null) 860 | { 861 | shellFolderKey.DeleteValue("Attributes", false); 862 | shellFolderKey.Close(); 863 | } 864 | } 865 | 866 | private static void DeleteRegistryClassesRootValue(string subkey) 867 | { 868 | RegistryKey shellFolderKey = Registry.ClassesRoot.OpenSubKey(subkey, true); 869 | if (shellFolderKey != null) 870 | { 871 | shellFolderKey.DeleteValue("Attributes", false); 872 | shellFolderKey.Close(); 873 | } 874 | } 875 | 876 | private static void RebootComputer() 877 | { 878 | Org.Mentalis.Utilities.WindowsController.ExitWindows( 879 | Org.Mentalis.Utilities.RestartOptions.Reboot, false); 880 | 881 | } 882 | private static void LogoffComputer() 883 | { 884 | Org.Mentalis.Utilities.WindowsController.ExitWindows( 885 | Org.Mentalis.Utilities.RestartOptions.LogOff, false); 886 | 887 | } 888 | } 889 | } 890 | --------------------------------------------------------------------------------