Add Show/Hide hidden folders to Windows 7 context menu

0

Recently I've been bugged by the fact that it is so difficult to turn on "Show Hidden Files" in Windows as compared to other OS (ie. Ubuntu). I've been searching for a way to add an option to "Toggle Hidden Files" to the Windows 7 context menu, but have come up with only 3rd party options. However, I would prefer doing it myself as opposed to a 3rd party option, merely for unnecessary functionality.

I am quite sure that there must be a way to do this with the Registry Editor, as adding other things to the context menu involves this (from what I can see with other tutorials). However, I have found nothing to do so yet. I am also assuming that I will need to use a script of some kind to be called from the Registry entry.

Does anyone have any experience with this? It would greatly improve my workflow, as I switch between wanting to see hidden files and hiding them quite frequently. Thanks!

Kendall

Posted 2016-06-13T13:43:38.807

Reputation: 103

Have you the methods for each step? 1. How to add new right-click options. 2. Which registry entry changes the visibility state of hidden files. 3. How to script the if/else - reg add so the registry value is alternated between 0 and 1. Step 3 may be possible with a single, long and difficult command, but I would go with a script. – benJephunneh – 2016-06-13T15:42:54.153

"It would greatly improve my workflow, as I switch between wanting to see hidden files and hiding them quite frequently." If you need to do this something is wrong with your workflow. What is the XY problem?

– DavidPostill – 2016-06-13T21:13:34.380

Answers

0

Next VBScript should do the job:

option explicit
On Error GoTo 0
Dim sResult: sResult = Wscript.ScriptName                            ''' debugging

Const HKEY_CURRENT_USER = &H80000001

Dim strComputer, strKeyPath, strValName, dwValue, arrValues, objReg, WshShell
arrValues = Array (" unknown", " show hidden files", " hide hidden files" )
strComputer = "."

Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
strValName = "hidden"

objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValName, dwValue

If Not (dwValue = 1 OR dwValue = 2) Then dwValue = 0

sResult = sResult & vbNewLine & CStr( dwValue) & arrValues( dwValue) ''' debugging

dwValue = (dwValue Mod 2) + 1                           ' switch value 1 <--> 2

sResult = sResult & " -> " & CStr( dwValue) & arrValues( dwValue)    ''' debugging

objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValName, dwValue

set WshShell = WScript.CreateObject("WScript.Shell")
    WScript.Sleep 30
    WshShell.SendKeys "{F5}"              ' refresh

Wscript.Echo sResult                                                 ''' debugging
Wscript.Quit

And following registry configuration file adds above script functionality to right-click context menu for any folder background in File Explorer (and for desktop background as well).

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\background\shell\Toggle Hidden Files]

[HKEY_CLASSES_ROOT\Directory\background\shell\Toggle Hidden Files\command]
@="C:\\Windows\\System32\\wscript.exe  \"D:\\VB_scripts\\SU\\1088687.vbs\""

Please, in above .reg file, customize next items to fit your circumstances:

  • menu item name Toggle Hidden Files and
  • full path to script D:\\VB_scripts\\SU\\1088687.vbs (note doubled backslashes).

To verify correctness:

==> reg query "HKCR\Directory\background\shell\Toggle Hidden Files" /s

HKEY_CLASSES_ROOT\Directory\background\shell\Toggle Hidden Files\command
    (Default)    REG_SZ    C:\Windows\System32\wscript.exe  "D:\VB_scripts\SU\1088687.vbs"

==>

Moreover, you could remove all lines containing sResult in above VBscript; then the script will do the job silently.

JosefZ

Posted 2016-06-13T13:43:38.807

Reputation: 9 121

I apologize for not getting back to this sooner! I got it working and then totally forgot about it! The only thing that this doesn't do (and I didn't ask for previously) is switch the context menu between "Hide Hidden Files" and "Show Hidden Files". But I definitely appreciate this! – Kendall – 2016-10-11T15:42:47.680

0

The Registry key you're looking for is here:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] "Hidden"=dword:0000000x

Set x to 1 to show the hidden files & folders, and set x to 2 to hide them.

So we'll make two files to help us out. We need to store them someplace, and I'll use the Documents folder in my examples.

Hidden Files & Folders - show.reg:

Windows Registry Editor Version 5.00

; Show hidden files & folders

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Hidden"=dword:00000001

Hidden Files & Folders - hide.reg:

Windows Registry Editor Version 5.00

; Hide hidden files & folders

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Hidden"=dword:00000002

You can now test these files work by clicking on them. You'll need to refresh ([F5]) to see the changes take effect.

Next, we need to make a registry change to add the right-click option. I'll assume that we only want to add the right-click option to folders. Here's a .reg file that will make the needed changes:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Folder\shell]

[HKEY_CURRENT_USER\Software\Classes\Folder\shell\Hide]
@="Hidden Files - &Hide"

[HKEY_CURRENT_USER\Software\Classes\Folder\shell\Hide\command]
@="reg import \"C:\\Users\\Jim\\Documents\\Hidden Files & Folders - hide.reg\""

[HKEY_CURRENT_USER\Software\Classes\Folder\shell\Show]
@="Hidden Files - &Show"

[HKEY_CURRENT_USER\Software\Classes\Folder\shell\Show\command]
@="reg import \"C:\\Users\\Jim\\Documents\\Hidden Files & Folders - show.reg\""

Now you can right-click on any folder, and select the Hide or Show option. You'll still need to do a View -> Refresh (or hit [F5]) to see the changes.

Note that this uses the location of my Documents folder. You'll need to make the appropriate changes for your computer.

We could make this more universal and use the %USERPROFILE% variable, but that requires they use of an expandable string which makes the .reg file more difficult to read and change, so I skipped it in the steps above. Also, I don't know where you really want to store the files, so I just kept it simple for now.

JimBurd

Posted 2016-06-13T13:43:38.807

Reputation: 1

This will not give him a toggle. It would be easy enough to script and then simply "reg add..." based on an if/else condition. – benJephunneh – 2016-06-13T16:36:05.610

Agreed. Was just offering a roadmap on how to solve it. – JimBurd – 2016-06-13T17:56:12.630