How to toggle Show/Hide hidden files in Windows through command line?
Solution 1
Hidden files, folders or drives:
Add (or overwrite /f
) the value Hidden
to the registry key: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
.
Show:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /d 1 /f
Don't show:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /d 2 /f
ToggleHiddenFiles.bat
REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden | Find "0x2"
IF %ERRORLEVEL% == 1 goto turnoff
If %ERRORLEVEL% == 0 goto turnon
goto end
:turnon
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /d 1 /f
goto end
:turnoff
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Hidden /t REG_DWORD /d 2 /f
goto end
:end
Hide protected operating system files (Recommended)
Checked:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t REG_DWORD /d 0 /f
Unchecked:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t REG_DWORD /d 1 /f
ToggleSystemFiles.bat
REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden | Find "0x0"
IF %ERRORLEVEL% == 1 goto turnoff
If %ERRORLEVEL% == 0 goto turnon
goto end
:turnon
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t REG_DWORD /d 1 /f
goto end
:turnoff
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowSuperHidden /t REG_DWORD /d 0 /f
goto end
:end
Notes: Changes take place immediately. The program reg
requires admin privileges, so run the batch files as administrator.
Solution 2
The property to show/hide hidden files is managed in the registry, so you would simply need a .reg file that simply toggles this property. Here is how you do it through registry:
- Type “regedit“, then press “Enter“.
- Navigate to the following location: HKEY_CURRENT_USER --> Software --> Microsoft --> Windows --> CurrentVersion --> Explorer --> Advanced
- Set the value for “Hidden” to “1” to show hidden files, folders, and drives.
- Set the value to “2” to not show hidden files, folders, and drives.
- Set the value for “ShowSuperHidden” to “1” to show protected operating system files. Set the value to “2” to not show protected operating system files.
If you give me a bit of time, I will write the REG file and post it here.
Edit: Steven seems to have posted an example script, so I won't build one.
Solution 3
Although not a command line function, here's a method on how to quickly open the window: Show hidden files and folders.
Caution: Review source information in Part 1 concerning Vista before proceeding.
Part 1: Create a folder that contains the object 'Show hidden files and folders'.
Part 2: Create a desktop shortcut of 'Show hidden files and folders'.
Part 3: Open the window for 'Show hidden files and folder'
After you have completed all 3 parts you will have a keyboard shortcut for quick access to the window for 'Show hidden files and folders'.
Part 1
- Right click a blank area of the desktop
- Click New
- Click Folder
- Name the folder: How-To Geek.{ED7BA470-8E54-465E-825C-99712043E01C}
Part 2:
- Open the How-To Geek folder you just created
- Click the arrow next to File Explorer Options if it's not already expanded
- Right click and drag to the desktop 'Show hidden files and folders'
- Click create shortcut here
Note: In this particular situation you could left click and drag, but it's always good practice to right click and drag to ensure you are performing the intended function, and because you can also click cancel if needed.
Part 3:
- Right click the shortcut folder on the desktop 'Show hidden files and folders'
- Click Properties
- On the Shortcut tab click in the Shortcut Key field
- Press something like Ctrl + Alt + T
- Click OK
- Press Ctrl + Alt + T and the 'Show hidden files and folders' will open
Related videos on Youtube
Comments
-
RogUE over 1 year
I often need to toggle between show/hide hidden files in my PC. I have been doing it the usual way,
- Click Organize in an Explorer window.
- Select Folder and search options.
- Switch to View tab.
- Toggle between Show/Hide Hidden files.
This method is so lengthy and I am tired of it.
I would like to toggle between them from the command line (cmd). Is there any way to achieve this?
Also, a way to toggle between Show/Hide System Files from the command line would be great.
-
IronWilliamCash over 7 years@RogUE : Yes, the ShowSuperHidden is for the system files that are hidden.
-
Steven over 7 years@RogUE I am unsure what the SuperHidden value does. However, it does always reset to zero whenever the View tab of the Folder Options applet is opened the first time.
-
Steven over 7 yearsCheck the setting. Close Folder Options. Run my toggle script. Repeat.
-
Zoredache over 7 yearsDon't you need to kill and restart the explorer.exe process for registry changes to actually get applied?
-
Steven over 7 years@Zoredache The settings take effect immediately either from the Folder Options and the registry change. Try it and see.
-
TripeHound over 7 years@RogUE No, because the script is testing the result of the
find
command (whether0x2
or0x0
is present in the registry key). -
TripeHound over 7 years@RogUE In the first script, the
REQ QUERY
command will be returning a string containing either0x1
or0x2
and thefind
command is looking for the presence (or not) of0x2
. If this string is found,find
returnsERRORLEVEL
of0
(zero is traditionally "it worked" in command-line programs); if0x2
wasn't found,find
will return1
. It is the return-code of thefind
command that is being tested in the next two lines. -
TripeHound over 7 yearsIt doesn't appear to be a typo: it's checking for the presence of
0x0
; if it's found (find
returns0
) then it jumps toturnon
and sets the value to1
; if it's not found (find
returns1
) then it jumps toturnoff
and sets it to0
. Either it's an arbitrary choice (and the test could have beenfind 0x1
with thegoto
s reversed) or it might be (I haven't checked) that0x1
is present in theREQ QUERY
output in either case and so cannot be used to tell the two settings apart. -
Steven over 7 years@RogUE Have you tried running the scripts?
-
RogUE over 7 years@Steven The toggle scripts did the job. Though I could not assign them to a keyboard shortcut, I ended up placing an icon on the desktop.
-
RogUE over 7 yearsI am not going to upgrade just for the sake of a keyboard shortcut.
-
CentrixDE over 2 yearsThis does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review