Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

Add (or overwrite /f) the value Hidden to the registry key: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced.

Hidden files, folders or drives:

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 the batch files must be run as administrator.

share|improve this answer
    
Can we combine both the commands to a single one that simply toggles the value, that is if it is 1, the command changes it to 2, if it is 2, then to 1? – RogUE 15 hours ago
    
No, I mean I just want to toggle one at a time. Lets talk about the Hidden Files. I need the first two commands(for Hidden Files, isn't it?) be combined to one.It only needs to simply toggle the value of the key, if the key's value is 1, change it to 2 and vice versa. – RogUE 15 hours ago
    
So that I don't have to have two seperate shortcuts(I intent to create a keyboard short cut), one to show hidden files and the other to hide hidden files. – RogUE 15 hours ago
    
Yep. Like this, 'if(hidenfile==1)hidenfile=2; else if(hiddenfile==2) hiddenfile=1;'. (Its a C++ code snippet, hope you can understand. I just wanted to make sure that you understood.) //This is for the HidenFiles – RogUE 15 hours ago
    
See edited answer with toggle scripts (which must be run as an administrator) – Steven 15 hours ago

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.

share|improve this answer
    
Theres two keys named ShowSuperHidden and SuperHidden, is there any difference? – RogUE 15 hours ago
    
@RogUE : Yes, the ShowSuperHidden is for the system files that are hidden. – IronWilliamCash 14 hours ago
    
What about the key SuperHidden ? – RogUE 14 hours ago
    
@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 14 hours ago
    
@Steven That's allright. I just wanted to make sure that the key is indeed 'showsuperhidden' which has to be changed. – RogUE 14 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.