Create Simple Script to Show / Hide Hidden Files and Folders in Windows

We have posted a tutorial in past to show / hide hidden files and folders quickly and easily in Windows. It provides 2 registry scripts to enable / disable “Show hidden files and folders” option on the fly:

Show/Hide Hidden Files & Folders on the fly in Windows

Hidden_Files.png

Advertisement

Today in this tutorial, we are going to share a small script which can also be used to enable / disable “Show hidden files and folders” option in Windows.

This script when executed, checks the status of “Show hidden files and folders” option and toggles its value. So if its set to show hidden files, it changes the option to hide hidden files and vice versa.

Simply copy paste following code in NOTEPAD and save the file with name “Show_Hidden_Files_On_Off.vbs” (including quotes):

Hidden = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
Set Sh = WScript.CreateObject("WScript.Shell")
St = Sh.RegRead(Hidden)
If St = 2 Then
Sh.RegWrite Hidden, 1, "REG_DWORD"
Else
Sh.RegWrite Hidden, 2, "REG_DWORD"
End If
Sh.SendKeys("{F5}")

That’s it. You can place this script at any location like Desktop, Quick Launch toolbar and whenever you need to toggle the “Show hidden files and folders” option, simply run the script.

Also check:

Create Simple Script to Show / Hide Checkbox to Select Items in Windows

Advertisement

Create Simple Script to Show / Hide File Extensions in Windows

Published in: Windows 7, Windows Vista, Windows XP

About the author: Vishal Gupta (also known as VG) has been awarded with Microsoft MVP (Most Valuable Professional) award. He holds Masters degree in Computer Applications (MCA). He has written several tech articles for popular newspapers and magazines and has also appeared in tech shows on various TV channels.

Comments

NOTE: Older comments have been removed to reduce database overhead.

  1. hi vg i have a problem with this one i have actually been using a similar script for toggling hidden files on one of my computers which is an xp but it started giving me an error about a month or 2 ago. the error says “can not find script engine ‘VBSCRIPT’ for script file.vbs”
    file.vbs is my script file. i found a vbscript.dll in the windows system folder but thats it, should there be a vbscript.exe or something? i tried using your script but it says the same thing. would u happen to know how to fix this? no rush, and thanks

  2. ^^ It seems some files are corrupt in your Windows. You can try to install Visual C++ Redistributable. Just search for it on Google. 😉

  3. Windows Registry Editor Version 5.00

    [-HKEY_CLASSES_ROOT\Directory\shell\toggleHiddenFiles]

    [HKEY_CLASSES_ROOT\Directory\shell\toggleHiddenFiles]
    @=”Show/hide system files”
    “HasLUAShield”=””

    [HKEY_CLASSES_ROOT\Directory\shell\toggleHiddenFiles\command]
    @=”cmd /q /d /c \”for /f \”tokens=3,*\” %%a in (‘reg query HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden’)do if \”%%a\”==\”0x1\” ((reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden /t REG_DWORD /d 0 /f>nul)&(reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v Hidden /t REG_DWORD /d 2 /f>nul)) else ((reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f>nul)&(reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v Hidden /t REG_DWORD /d 1 /f>nul))\””

    [-HKEY_CLASSES_ROOT\Directory\Background\shell\toggleHiddenFiles]

    [HKEY_CLASSES_ROOT\Directory\Background\shell\toggleHiddenFiles]
    @=”Show/hide system files”
    “HasLUAShield”=””

    [HKEY_CLASSES_ROOT\Directory\Background\shell\toggleHiddenFiles\command]
    @=”cmd /q /d /c \”for /f \”tokens=3,*\” %%a in (‘reg query HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden’)do if \”%%a\”==\”0x1\” ((reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden /t REG_DWORD /d 0 /f>nul)&(reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v Hidden /t REG_DWORD /d 2 /f>nul)) else ((reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f>nul)&(reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v Hidden /t REG_DWORD /d 1 /f>nul))\””

    [-HKEY_CLASSES_ROOT\Drive\shell\toggleHiddenFiles]

    [HKEY_CLASSES_ROOT\Drive\shell\toggleHiddenFiles]
    @=”Show/hide system files”
    “HasLUAShield”=””

    [HKEY_CLASSES_ROOT\Drive\shell\toggleHiddenFiles\command]
    @=”cmd /q /d /c \”for /f \”tokens=3,*\” %%a in (‘reg query HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden’)do if \”%%a\”==\”0x1\” ((reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden /t REG_DWORD /d 0 /f>nul)&(reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v Hidden /t REG_DWORD /d 2 /f>nul)) else ((reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f>nul)&(reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced /v Hidden /t REG_DWORD /d 1 /f>nul))\””

  4. Need a Vbscript to enable or disable error reporting feature.. Please.. 🙂

  5. ^^ The Registry key location is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PCHealth\ErrorReporting

    And the DWORD is DoReport

  6. I know that sir. I need vbscript.. Like show extention on_off.vbs by u… which means in i click it once enable..again if i click disable..

  7. ^^ I mean the same. Just replace the Registry key name and DWORD name in vbscript with the one I provided.

  8. VG plz if u dont mind can u rewrite it here.. I couldn’t understand.. Plaese..

  9. ^^ Following should work:

    DoReport = “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PCHealth\ErrorReporting\DoReport”

    Set Sh = WScript.CreateObject(“WScript.Shell”)

    St = Sh.RegRead(DoReport)

    If St = 0 Then

    Sh.RegWrite DoReport, 1, “REG_DWORD”

    Else

    Sh.RegWrite DoReport, 0, “REG_DWORD”

    End If

    Sh.SendKeys(“{F5}”)

  10. Thanks a lot VG..It worked.. 🙂

    ***********************************************************
    DWORD = “Registry Location”

    Set Sh = WScript.CreateObject(“WScript.Shell”)

    St = Sh.RegRead(DWORD)

    If St = 0 Then

    Sh.RegWrite DWORD, 1, “REG_DWORD”

    Else

    Sh.RegWrite DWORD, 0, “REG_DWORD”

    End If

    Sh.SendKeys(“{F5}”)

    ************************************************************
    Is this the Basic to create that type Vbs scripts.. ?

  11. how to recover hidden folder and files by virus through a vb script ? any possibility

  12. Another great article. Not an expert, but don’t have to be to recognize a good/bad thing. Don’t forget to mention (I don’t think you did) that this script ALSO unhides “PROTECTED OPERATING SYSTEM Files” as well, and ALSO does this for “hidden files”. The script reverts/toggles the settings back to other state when clicked second time (I tested it, it works on win7 x64 home premium).

    This is (ie. mammoth process of unhiding/hiding files) very infuriating process, and the script is JUST WHAT I NEEDED! Thanks once again VG. Windows 7 has many of these infuriating “little details” left out which takes forever to get to a system that is what I would call very good. It is also infuriating that one has to depend on potentially malicious software (free, as one would have to be J. Paul Getty to afford getting just a REASONABLE system!) that makes it near impossible to create a windows 7 (ie. loaded with much needed software/tweaks) system without having to reinstall and tweak over and over again as some piece of software comes along and disturbs nirvana. Your site is very good so keep up the good work on computer programming (ie. don’t go to India and do bare handed tiger hunting when your are contributing something positive to the world with your computer knowledge & teachings, and keep the old dot from getting bent out of shape!) as you seem to come up with a lot of good things that are helpful/useful.

  13. Is there a way to auto refresh the folder after clicking or making a windows balloon popup saying that they’re visible/hidden, simply by tweaking the script?

  14. is there a way to clean the temporary internet files as well as hiding hidden folders? this would be very useful to me

  15. my windows not be show/hidden and i try This script and show me message a error

    please i need registry file to solve this problem

  16. Great script works like a charm!
    fyi: i have admin rights on the laptop not sure if that might be an issue for some of the others that this is not working for

  17. Hi everyone…
    Is there any script in windows to check whether someone has accessed a file or folder which is restricted.

    Thank you

Leave a Comment

Your email address will not be published. Required fields are marked *

NOTE: Your comment may not appear immediately. It'll become visible once we approve it.