One of the things that I’ve always done on my Windows computers is have them show all of the hidden files. Some people think I’m crazy because this adds a lot more clutter, but it always seemed as though I frequently had to access files there were otherwise hidden. Sure I liked when some files were out-of-sight because I only ever mess with a handful of them, but the hassle of going into the Windows Explorer options every time I needed to see some hidden files just wasn’t worth it.
After a little research I had come across an article on the PCWorld forum that outlined how I could create a shortcut that would enable or disable hidden files on the fly. If the setting is enabled it would disable it when run, and vice versa. It’s one shortcut that serves as an on/off switch for hidden files. Here’s how you do it:
- Open up Notepad and paste in the following text:
Set sh = CreateObject("WScript.Shell")
theKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
setHidden = sh.RegRead(theKey)
If setHidden = 1 Then
setHidden = 0
MsgBox "System and hidden files will no longer appear in Explorer.",64,"Hidden File Exchange"
Else
setHidden = 1
MsgBox "System and hidden files will appear in Explorer.",64,"Hidden File Exchange"
End If
sh.RegWrite theKey,setHidden,"REG_DWORD"
Set sh = Nothing - Save the file with any name you want, but make sure to designate the extension to be “.vbs”:

- Run the file that you just saved. Give it a few seconds to take affect, but you should see the results without even having to restart Windows Explorer.
- If you want you can place this script file anywhere you’d like on your computer, and then you can create a shortcut to it by right-clicking on the file. I recommend placing a shortcut to the file in the Windows Explorer Favorites for fast access from the Favorites menu.
Compatibility: I’ve verified that this works on Windows XP, but it only works on Vista when User Account Control (UAC) is disabled. This is because it needs access to the registry, and Vista doesn’t allow that unless it is run as an administrator. Since it is a VBS file the “Run as Administrator” option does not appear when right-clicking on the file.
By default the script will prompt you with the current setting for the hidden files each time you run the script. That way you know whether you are turning them on or off. If you don’t want to see the prompts just remove the following two lines that I’ve highlighted in the code:

Now you are all set with a shortcut that can enable or disable hidden files in Windows Explorer. This should help reduce the clutter you see on a regular basis by keeping the hidden files out-of-sight when they’re not needed, and then pulling them up when you need to make a change. How convenient is that?


This is a really neat shortcut. Thanks for this. It will be very useful to me.
Nice hint! I’ll keep this script around, but I use HiddenFilesToggle (a Contextual Menu (CM) item):
[msfn.org]
nice; i guess a similar thing for “show/hide extensions for known filetypes” would be easy (anyone know how to do it?)
I tried this script, and it doesn’t really work for me (WinXP SP2). It detects the current Hidden state, and toggles the setting in the Registry, but the hidden files do NOT toggle on/off. What’s missing is some type of “broadcast” message that tells Explorer to reload or something. You can see this when you bring up a File Type setting from the Explorer Folder Options and then dismiss it (you can see Explorer refresh, and your hidden files will toggle if you had run this script previously).
Any way to include the broadcast in this script? :!:
I haven’t found a way to broadcast to Windows Explorer that a change has been made, but it took less than 5 seconds for Windows Explorer to detect the change on my XP machine.
Hi, to broadcast the info, you have to
- enum processes to find all explorer.exe and get their pids
- get their window handle
- post to each window the following message:
WM_COMMAND, 41504, 0 (vista)
WM_COMMAND, 28931, 0 (xp (and previous?))
Or, there ‘s a nice shell toolbar here that have the feature and it is imediate: [tools.tortoisesvn.net]
Thanks for the easy to follow instructions. This is a useful tip indeed!
Nice tip!!BTW,I also need another shortcut for show/hide file exetension in windows.
You might get a bit more technical, learn programming (are you really a developer u say?) and call this a script, not be shortcut. :D
Now I have ever faster access to my pron!!! ;)
I mentioned that you can create a shortcut to the script, and so this does tell you how to create a shortcut to do the deed.
reallly nice shortcut m8..i will try this one
I’m running Windows Vista as a limited user (not admin), with UAC turned on, and this worked a treat – it doesn’t even ask for the admin password, or confirmation that i want to allow it to run. You do have to refresh Explorer for it to take effect though. If you create a shortcut to the VBS file, and then look at the properties of that shortcut, you can give it a keyboard hotkey as well: I’m using Ctrl+Alt+H. sweet!
That’s odd, it’s not supposed to execute registry modifications without a UAC prompt?
pure genius!!! thanx!!!
Now how about telling us how to make a keyboard shortcut to this file. :P
Thanks for this great script! :D
@Naveed: you could try a launcher like Launchy or Executor. :)
Why should it? HKCU or HKEY_CURRENT_USER is writable for the user. You do not need Admin privileges to modify this setting via the UI either.
Instead of displaying message of state, I replace with refresh so you don’t have to. Here’s the modified script:
Set WshShell = CreateObject(“WScript.Shell”)
theKey = “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden”
setHidden = WshShell.RegRead(theKey)
If setHidden = 1 Then
setHidden = 0
WshShell.SendKeys “{F5}”
Else
setHidden = 1
WshShell.SendKeys “{F5}”
End If
WshShell.RegWrite theKey,setHidden,”REG_DWORD”
Set WshShell = Nothing
hi all,
in this code, replace ” with “
” , ” = double Quotations
It DOENST work properly in my vista, UAC IS turned off and I AM an ADMIN.
FIX: it does work, but u need to refresh…
Works, but only on the system drive. Anyway to get it to work across all drives? 64 bit Vista
nice work!!!!!!!!!!!!!!!
yeah!!!!
Great work.
My Windows made me disgusted when I had used to click options/…
I’ve already got rid of it.
Thanks a lot.
Hmmm. On my XPH SP3, neither scripts seem to work. The first (original posted) one does display the notifications, but even after several minutes, nothing happens. Even tried second script (John’s) and it promted a WCH error (line 1, char 29, invalid charactoer, 800A0408). Then after seeing John’s script’s added W’s (ahead of ‘Wsh’ entries), when I removed those W’s, re-tried the script, same WSH error, ie; no joy. Maybe my AV (McAfee’s default settings) messes with this? Oh well, glad it reportedly works for others.
Just discovered the posts’s initial script (when right-clicking the desktop and selecting “refresh”, does work on my XPH SP3 (I’m sure, McAfee’ or no). So three simplier steps are better than the XP default alternatives. Kudos to whomever.
Add this to the end of the code to make it AUTO-REFRESH (F5) in Vista32:
Set WSHShell = WScript.CreateObject(“WScript.Shell”)
strDesktop = WSHShell.SpecialFolders(“Desktop”)
WSHShell.AppActivate strDesktop
WSHShell.SendKeys “{F5}”
WScript.Quit
Thanks for the tip!!!
do u have a code autorefresh for win 7 64?
Thanks!
Now the fun part, adding it to the right-click menu of a folder :)
Thanks. Awesome.
What’s wrong with going into folder options and enabling this the sane way as opposed to exposing your system to good old insecure VBScript?
You try and do this 10x a day, I want to see you ask that same question again.
Great script, I modified it slightly so it would work on 64bit Windows 7. The change enables a UAC prompt by using a script snippet found at [insidethe.com] .
Here is the modified UAC enabled script:
If WScript.Arguments.Named.Exists(“elevated”) = False Then
‘Launch the script again as administrator
CreateObject(“Shell.Application”).ShellExecute “wscript.exe”, “”"” & WScript.ScriptFullName & “”" /elevated”, “”, “runas”, 1
WScript.Quit
Else
‘Change the working directory from the system32 folder back to the script’s folder.
Set oShell = CreateObject(“WScript.Shell”)
oShell.CurrentDirectory = CreateObject(“Scripting.FileSystemObject”).GetParentFolderName(WScript.ScriptFullName)
Set sh = CreateObject(“WScript.Shell”)
theKey = “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden”
setHidden = sh.RegRead(theKey)
If setHidden = 1 Then
setHidden = 0
MsgBox “System and hidden files will no longer appear in Explorer.”,64,”Hidden File Exchange”
Else
setHidden = 1
MsgBox “System and hidden files will appear in Explorer.”,64,”Hidden File Exchange”
End If
sh.RegWrite theKey,setHidden,”REG_DWORD”
Set sh = Nothing
End If
Thanks Buddy…………
Great. Thanks :-)
I was looking for that to save it as as a shortcut in a utilities desktop gadget. Worked great with windows 7
Thank’s a lot
Worked great with windows 7 32 bit :)
nice trick, worked greatly on xp sp2
tanks a lot
thank you very much ^_^ it helps me so much, thank you
It says it cant run a .vb file… im not the biggest computer savvy guy but i can copy and paste like a pro.. any help?
windows 7 64bit