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

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"

SHidden = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden"

Set Sh = WScript.CreateObject("WScript.Shell")

St = Sh.RegRead(Hidden)

If St = 2 Then

Sh.RegWrite Hidden, 1, "REG_DWORD"

Sh.RegWrite SHidden, 1, "REG_DWORD"

Else

Sh.RegWrite Hidden, 2, "REG_DWORD"

Sh.RegWrite SHidden, 0, "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.

PS: If you don't want to create the script manually or face any problem while creating the script, you can download a ready-made script using following link:

Download Script

Also check:

Add "Show/Hide Hidden Files" Option in Desktop/Explorer Context Menu in Windows





Share this article: Facebook | Twitter | Google+ | Reddit | Tell a friend

Posted in: Windows 7, Windows Vista, Windows XP


Other similar articles that may interest you


Comments

  • 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

  • VG

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

  • Was searching for this a long time. Thanks alot for the easy script! Love it.

  • 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))\""

  • Need a Vbscript to enable or disable error reporting feature.. Please.. :)

  • VG

    ^^ The Registry key location is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PCHealth\ErrorReporting

    And the DWORD is DoReport

  • 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..

  • VG

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

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

  • VG

    ^^ 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}")

  • 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.. ?

  • VG

    ^^ Absolutely.

  • Thanks lot VG...Thanks for ur suppoprt :) :)

  • Very useful script
    Only seems to change the folder that the script is located in XP

  • Great work bud. Thanks!

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

  • 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.

  • thanks so much. was such a hassle - poor access to this with ms!

  • how to check hidden folder using vbscript?

  • 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?

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

  • I keep getting pop up ads on my browser pages. "Ads By Provider". I can usually find the extensions and remove them BUT this one is hiding somewhere in my computer. How else can I locate this. It's very annoying!!

  • 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

Leave a Comment

(required)