Tip of the day: Show hidden files with a simple script

In its default settings, Windows Explorer conceals two types of files: those with the hidden attribute set, and those designated as system files. Some people, including my occasional writing partner Woody Leonhard, think you should always enable the display of hidden files. I don’t agree – in general, I prefer to keep system and hidden files hidden except when I need to solve a particular problem. To change Explorer’s settings so hidden and system files are visible, open any Explorer window and click Tools, Folder Options (or click the Folder Options icon in Control Panel). On the Folder Options dialog box, click the View tab and select the Show hidden files and folders checkbox. Then scroll down a bit further and clear the Hide protected operating system files (Recommended) checkbox. (You’ll have to click past a warning dialog box to make this change.) When you close the dialog box and return to the Explorer window, you’ll see all the files in that folder, including those marked as hidden and system files.

Show_hidden_files

It is annoying to make this change, and equally annoying to undo the change when you’re finished with the current task. So for Windows XP Inside Out, we came up with a script that automates the process. The script examines the registry to see whether hidden files (those with the Hidden attribute set) are displayed in Windows Explorer. If not, it modifies the registry so that hidden files and super-hidden files (those with the System and Hidden attributes set) are displayed. The script also assumes that you probably want the option to edit file name extensions, so it changes settings to make all file name extensions visible as well. If hidden files are already displayed, the script assumes you want to undo the previous set of changes and modifies these three registry values accordingly.

I’ve made the script file available for download in compressed (Zip) format: Click here to download the file, extract it to a convenient location, and run it whenever you want to toggle hidden files.

If you want to view the script contents first, click here to see the text in a separate browser window. Remember to save the script file with the .vbs extension.

When the script runs, it changes the current settings and displays the results in an information box. If the script won’t run properly on your computer, check to see whether your anti-virus or security software is blocking Visual Basic script files.

38 thoughts on “Tip of the day: Show hidden files with a simple script

  1. I think the issue isn’t so much with recommending that option to be on as it is with the implementation. Hidden files are about viewing the files not actual properties of a file. In file dialogs and file browsers, I should be able to create views of a folder to see what I want. Hidden files deal with viewing files not the file itself. The Microsoft implementation puts the hidden property on the file though.

  2. Nice. Exactly what I was looking for. I use an icon association program that drops a settings file in each folder including the desktop and it’s nice to hide those. Less clutter is better too.
    Thanks, rock on.

  3. This is really useful, but I need one which just disables super-hidden. How would I edit this to do that?

  4. Dee,

    You should be able to accomplish what you’re looking for by deleting the line that begins with “IF” and then deleting the “ELSE” line and everything that follows it.

  5. THANKZZZ!!! Weeks ago the soraci.b infected my machine, I could clean it but the “Folder Options” button dissapeared, I tried to fix it with the windows registry and nothing happened, you save my life!! Now i can see the hidden files and (in the next infection) I’ll can clean my computer again.

    Thankz so muuuchhh!!!! 😀 😀 😀 😀 😀

  6. Hi everyone. I just finished copying all of my Office documents from my desktop to my new laptop. Unfortunately some folders/files are now showing up as “hidden” and the toggle to make then “unhidden” is whited out in the properties section. Anybody know of a way to fix this problem? It’s not critical but really annoying. Unfortunately those folders/files that have been tagged “hidden” show no pattern (and yes, I did go into windows property and click on “show all files” option). Thanks for help!

  7. Kathy,

    If the files are in your My Documents folder, and you are comfortable with the command line, you could try this option. Click Start, Run. In the Open box, type cmd and then press Enter. This opens a command window. Log on to your My Documents folder so it is showing as the current path. (If necessary, type CD %userprofile% and then cd “My Documents” (be sure to include quotes).)Now type the following:

    attrib -h . /s

  8. Hi Ed, thanks so much for your help; at least I’ve learned about the attrib function. I did what you said but for each of the problem folders it says “not resetting system file”. Recopying these folders from the source hasn’t fixed the problem either. Any other ideas?

    Kathy in Arlington, VA

  9. That is because it is both system and hidden file. Use the command line and take off both at the same time will do the trick.

    attrib -h -s . /s

  10. ed bott was correct

    you need to take ownership of the Dir/files

    if you have simple file sharing enabled(xp default) you need to disable that in folder settings and then right click on the files/Dir security tab/advanced/owner
    choose either your user name or administrator.

  11. P.S. if they are all in one dir choose the dir to take ownership of (or create one) and do the same but make sure you check mark “Replace qwner on subcontainers[folders]and objects[files}” .This will act like a batch process on all dir and files in that folder 😉

  12. hello!
    Your script works fine but I have a problem. I’ve used this script as my Folder Options under Tools is missing. 😦 How to put it back?

  13. Hi,
    I’ve tried this script, and it does change the values it is supposed to in the registry, but the change isnt reflected in explorer, not even after pressing F5, switching folders or restarting explorer. The change only comes into place if i go tools>folder options, select the view tab then click OK, then press F5. Any ideas how to get around this? I’m using XP x64 Pro if that helps.

    Thanks, Simon

  14. Simon, this tip was written before the launch of 64-bit Windows XP, so it doesn’t reflect that product. I honestly have no idea how to make it work, and don’t have the time to research it. Sorry.

  15. Hi Sir:

    May I ask if you had the chance to look into answer #21 above. Thanks.

    Simon H says:
    Hi,
    I’ve tried this script, and it does change the values it is supposed to in the registry, but the change isnt reflected in explorer, not even after pressing F5, switching folders or restarting explorer. The change only comes into place if i go tools>folder options, select the view tab then click OK, then press F5. Any ideas how to get around this? I’m using XP x64 Pro if that helps.

    Thanks, Simon

    Ed Bott says:
    Simon, this tip was written before the launch of 64-bit Windows XP, so it doesn’t reflect that product. I honestly have no idea how to make it work, and don’t have the time to research it. Sorry.

    Posted April 29, 2007 @ 9:12 am

  16. Simon, as far as I’m concerned, XP 64 is an incomplete and orphaned product and I don’t have the resources to research it. If you’re serious about 64-bit computing on Windows, you really should be running Vista x64, period.

  17. Thanks. My question was nicely written by others and you have already answerd and indicated in #20 + #21. However, thanks for answering it again.

    My PC uses XP and the confusing thing is that your approach refresh and is in agreement with one of MS’ articles. I guess that what MS called Refresh (Right Click on Desktop and Press Refresh) is not really the same Refresh as yours. Probably, MS Refresh is something else but MS calls it (whatever that is) Refresh anyhow.

    Is there a way to do using VB what one of your readers raised … that is: to update the PC screen, or re-apint the screen, or update the list of folders in the Windows Explorer (files & subfolders)? I feel that is the solution.

    Thanks

  18. Code:

    WS = CreateObject(“WScript.Shell”)
    WS.RegWrite(“HKCU\SYSTEM\CurrentControlSet\Control\Update\UpdateMode”, 0, “REG_DWORD”)

    does not update the screen “immediately.”
    why? or how to update the screen immediately?

    Thanks

  19. Greetings,

    Are any of your members willing to supply what I’ve been unable to locate for myself? (Before proceeding further, I should add that, not only am I not a member, at a week away from my sixtieth birthday, I feel I am just a little long in the tooth to start learning new tricks). Anyway, what I’m seeking is a script that will emulate/call upon the mouse right-click refresh command in Windows Explorer (Windows XP Pro File Manager). Please note that neither “F5” nor “Ctrl+R” are satisfactory since they are more than a little spasmodic in their responses, so I assume that the mouse command is calling upon a different function.

    The reason for desiring this script is that I’d appreciate a more elegant alternative to my existing system. Thanks to Google (and its creator, of course), I’ve found a script that will toggle “Show/Hide File Extensions”. This operates practically instantaneously but its effect cannot be seen until the window is refreshed (repainted?). I’ve tried various things to complete the change smoothly, none of which have been successful (NirCmd and modifying the Registry amongst others).

    At present, I’m using an executable (created from a macro) to show the change, but this relies on the Explorer window being in a central position and the area beneath the called-for mouse position being blank. The command file runs from a shortcut on the Quick Start bar that in turn runs a two-part command, the first part being the extension toggle script and the second, the refresh executable.

    (If it’s of any assistance, the toggle script I’m using, slightly modified to remove its original message panes, is:
    Option Explicit
    Dim RegValue, strFileExtKey
    Dim strKey, WshShell
    On Error Resume Next

    strKey = “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced”
    strFileExtKey = strKey & “\HideFileExt”

    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    RegValue = WshShell.RegRead(strFileExtKey)

    If RegValue = 1 Then
    WshShell.RegWrite strFileExtKey, 0, “REG_DWORD”
    WshShell.Run “%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters”, 1, True
    Else

        WshShell.RegWrite strFileExtKey, 1, "REG_DWORD"
        WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, True
    

    End If
    )

    So, can you help me? I appreciate that my needs are far from urgent but I’m enough of a “geek” to want things to be as neat as possible. Finally, I apologise for being somewhat long-winded (I plead my age as an extenuation!) but I wanted to ensure that there is no confusion about exactly what it is I’m searching for.

    With grateful thanks in advance,

    Dave Weightman

  20. hey is there a way to integrate this script in the right-click menu? or just make a keyboard shortcut for it? thanks

  21. Noob: To make a keyboard shortcut, first create a shortcut to the script file (drag it with right mouse button and select create shortcut) then right click on that shortcut, and select properties. There will be a entry area labled “Shortcut key” select it and hit your desired button.
    As to the right click menu, it is possable but I would need to know what exactly you mean (As in what exactly you are right clicking on)http://www.jfitz.com/tips/rclick_custom.html

    Now… on to MY question.
    I can edit the script to only toggle the show hidden files & folders, but I want modify the script to change the icon of it’s shortcut (we’ll assume it’s on the desktop) to be either a folder (when showing hidden) or a transparent icon (when hideing) thereby giveing me a visual que of if hidden is toggled ON or OFF before I run the file. Can anyone assist?

  22. Dave: Check the sight I listed above for context info to research what right click refresh is actualy calling up. I think the right click refresh is more akin to closeing the folder and reopening it. I don’t recall how to determine what windows explorer has open and it would take some research to accomplish smoothly, therefore I’ll wait for another more recent request before I look into it that deeply.

  23. First off, This must be the longest tip of the day, over 3 yrs !

    Ed , your a life saver, I’m always in and out of the ”hidden” system as I use the desktop.ini file to control my customised folder icons.
    I haven’t a clue why this started happening but all of a sudden (i.e. yesterday a.m) if I tried to hide/show either files or extensions as soon as I hit the ”apply” tab my PC froze with the only way out was the good old power off button.

    Any ideas why this would suddenly start happening ?

  24. This is am amazing script. I have been looking for this script for one long time. Thanks A Million. 🙂

Comments are closed.