How to toggle Show/Hide hidden files in Windows through command line?
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.
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.