I decided to take the keys and commands that Ben supplied and write a single batch file that toggles both the
ShowSuperHidden values on or off together.
Toggling Hidden/Super-Hidden Files with a Batch File
You can download ToggleHidden.bat here, but if you'd prefer to copy the script into a
.cmd file yourself, here's the source code:
REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Hidden" | Find "0x0"
If %ERRORLEVEL% == 0 goto show
IF %ERRORLEVEL% == 1 goto hide
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /f /d 1 > NUL
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t REG_DWORD /f /d 1
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /f /d 0 > NUl
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t REG_DWORD /f /d 0
echo There was an error! Check the script.
taskkill /f /im explorer.exe
A breakdown of what the script does: it queries the data of the
Hidden value; if it's off, it toggles both it and
ShowSuperHidden on. If it's already on, it toggles both it and
ShowSuperHidden off. I decided to design the script in this way because it's rare that I personally need to see hidden files without also seeing system files, but you can change this behaviour if you prefer.1
After either enabling or disabling these registry values, the script then kills and restarts the Windows Explorer explorer process. If, for some reason, the value of
Hidden can't be determined by the
query command then the script breaks and echoes an error before exiting.
Mapping the Batch File to a Hotkey
To satisfy my criteria for maximum convenience, I placed the newly-created
ToggleHidden.bat file somewhere on my computer and used AutoHotKey to map a hotkey combination to run it. I did this by adding the following to my existing AHK script:
Ctrl & H::
I used AutoHotKey here because I already use it for similar purposes and find it the more useful method of assigning hotkeys to run my programs, but if you'd rather not have to install AHK for the purpose of this step, you can also use this native Windows method for assigning hotkeys to a program.
I can now use the hotkey combination Ctrl+H to hide and quickly show or hide hidden/system files at my convenience... and it works beautifully, if I do say so myself.
1 If you do plan to go down this route, it's worth noting that, in the Windows ecosystem, superhidden files/folders act as a subset of hidden files/folders.
What this means when it concerns these two registry values is that you can enable the
Hidden value without enabling
ShowSuperHidden, but you can't enable
ShowSuperHidden without enabling
Hidden; doing so will show you only normal items, because Windows considers superhidden items a type of hidden item, and if hidden items are hidden, so are superhidden items. To put it simply: if you're planning to turn on
ShowSuperHidden, you need to make sure you turn on
Hidden with it.