Disclaimer >> You can find the original project and/or source in codeproject under the creator's name Gun Gun Febrianza.
Perfect for beginners.
Useful to some, useless to others.
The creator left us a little message about the program:
Straight to the point. But not giving a lot of info either.
We can Google ss64/nt/syntax-nodrives and learn more about this.
And even a deep quote by Carl Jung😁
Now that we know what we're doing, let's peek the code.
First thing we encounter is a restart() function
After hiding our drive(s) we are required to logoff/reboot in order to see the changes.
This function kills the process explorer.exe (which is charge of displaying the UI) and runs it again. This allows us to see the changes without rebooting or logging off.
Terminating the process via Task Manager will force you to start a new task as it won't start by itself. Just in case someone wondered.
Let's continue exploring the *magic* behind scenes
As we already know what we are doing, this function is pretty self explanatory.
Creating a registry key with the values "NoDrives" and value 4.
Why 4? It's the value needed in order to hide the C: drive.
More info can be found at the original project, you can click below to see other values.
Spoiler (Click to View)
Finally we close the registry and invoke the restart() function we talked about before, allowing us to see the changes in our system.
I don't need to explain that this doesn't protect/encrypt your drive(s), right?
Regards,
Perfect for beginners.
Useful to some, useless to others.
The creator left us a little message about the program:
Gun Gun Febrianza Wrote:We must create a subkey in HKEY_CURRENT_USER and this is the path Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer we must create DWORD 'NoDrives' with value 4. Value 4 is used for hiding drive 'C'.
Straight to the point. But not giving a lot of info either.
We can Google ss64/nt/syntax-nodrives and learn more about this.
SS64 Wrote:Copy the result into the registry to hide the drive letter(s)
User Key:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
System Key:
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
Value Name: NoDrives
Data Type: DWORD
After changing the registry, logoff or reboot so that it takes effect.
This entry stores the setting of the 'Hide these specified drives' in My Computer Group Policy. Group Policy adds this entry to the registry when you enable the policy. If you disable the policy or set it to Not configured, Group Policy deletes this entry from the registry, and the system behaves as though the value is 0x0.
Drive mappings hidden with a nodrives registry setting are still available, just type the drive letter into the Windows explorer address bar.
And even a deep quote by Carl Jung😁
Quote:“The dream is the small hidden door in the deepest and most intimate sanctum of the soul, which opens to that primeval cosmic night that was soul long before there was conscious ego and will be soul far beyond what a conscious ego could ever reach” ~ Carl Jung
Now that we know what we're doing, let's peek the code.
First thing we encounter is a restart() function
Code
private void restart()
{
Process p = new Process();
foreach (System.Diagnostics.Process exe in System.Diagnostics.Process.GetProcesses())
{
if (exe.ProcessName == "explorer")
exe.Kill();
}
}After hiding our drive(s) we are required to logoff/reboot in order to see the changes.
This function kills the process explorer.exe (which is charge of displaying the UI) and runs it again. This allows us to see the changes without rebooting or logging off.
Terminating the process via Task Manager will force you to start a new task as it won't start by itself. Just in case someone wondered.
Let's continue exploring the *magic* behind scenes
Code
private void button_HideDrive_click(object sender, EventArgs e)
{
try
{
if (comboBox1.SelectedItem.ToString() == "C")
{
string noDrive = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
RegistryKey regKey = Registry.CurrentUser.CreateSubKey(noDrive);
regKey.SetValue("NoDrives", Convert.ToInt32("4", 16), RegistryValueKind.DWord);
regKey.Close();
MessageBox.Show("Drive hidden successfully");
restart();
}
}
catch
{
MessageBox.Show("Something went wrong\n Try running with admin privileges");
}
}As we already know what we are doing, this function is pretty self explanatory.
Creating a registry key with the values "NoDrives" and value 4.
Why 4? It's the value needed in order to hide the C: drive.
More info can be found at the original project, you can click below to see other values.
Spoiler (Click to View)
Finally we close the registry and invoke the restart() function we talked about before, allowing us to see the changes in our system.
I don't need to explain that this doesn't protect/encrypt your drive(s), right?
Regards,

