Windows – How to toggle Show/Hide hidden files in Windows through command line

command linesystem-filewindowswindows 7

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.

Best Answer

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.

Related Question