Easy toggle to show / hide hidden files in Explorer.

Technical Q&A involving operating systems, networking, software, and hardware issues.

Moderator: jasonb

Post Reply
User avatar
jasonb
Site Administrator
Posts: 105
Joined: Tue Apr 22, 2003 1:54 pm
Location: Toronto, Canada
Contact:

Easy toggle to show / hide hidden files in Explorer.

Post by jasonb »

I don't like seeing a lot of the hidden files in Vista - such as the incredibly annoying "ProgramData" directory. (It would be less annoying if there were actually a space between the two words.) But I do want to see everything at times, I just don't want to go through the hassle of "reprogramming" Explorer options.

I did a quick Google search and came up with the following .vbs script authored by Ed Bott:

Code: Select all

' Script to toggle Windows Explorer display of hidden files,
' super-hidden files, and file name extensions

Option Explicit
Dim dblHiddenData, strHiddenKey, strSuperHiddenKey, strFileExtKey
Dim strKey, WshShell
On Error Resume Next

strKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
strHiddenKey = strKey & "\Hidden"
strSuperHiddenKey = strKey & "\ShowSuperHidden"
strFileExtKey = strKey & "\HideFileExt"

Set WshShell = WScript.CreateObject("WScript.Shell")
dblHiddenData = WshShell.RegRead(strHiddenKey)

If dblHiddenData = 2 Then
	WshShell.RegWrite strHiddenKey, 1, "REG_DWORD"
	WshShell.RegWrite strSuperHiddenKey, 1, "REG_DWORD"
	WshShell.RegWrite strFileExtKey, 0, "REG_DWORD"
	WScript.Echo "Windows Explorer will show hidden files and file " & _
		"name extensions. You might need to change to another folder " & _
		"or press F5 to refresh the view for the change to take effect."
Else
	WshShell.RegWrite strHiddenKey, 2, "REG_DWORD"
	WshShell.RegWrite strSuperHiddenKey, 0, "REG_DWORD"
	WshShell.RegWrite strFileExtKey, 1, "REG_DWORD"
	WScript.Echo "Windows Explorer will not show hidden files or file " & _
		"name extensions. (These are the default settings.) You might " & _
		"need to change to another folder or press F5 to refresh the " & _
		"view for the change to take effect."
End If
I took the liberty of removing the WScript.Echo statements (I want it to happen silently), and commenting out the FileExtKey entries (I want to always see the file extensions) - making this just toggle on and off all hidden files. It's on my quick launch bar right next to my Explorer shortcut..

The only issue is that the Explorer view doesn't refresh automatically, so I have to run this and then hit F5 myself. If I find a way of doing this via the script I'll update this.
Post Reply