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.
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