John's Computer Journal: Ctrl - Alt - H to Show and Hide Hidden Files

Wednesday, May 28, 2008

Ctrl - Alt - H to Show and Hide Hidden Files

Hidden files can quickly be shown and hidden again using the the following VBScript. The script has only been tested in Windows Vista, but should work in other versions of Windows.

'showHiddenFiles.vbs
'http://johnscomputerjournal.blogspot.com

Dim WSHShell, n, p, itemtype, MyBox
Set WSHShell = WScript.CreateObject("WScript.Shell")

p = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"

itemtype = "REG_DWORD"

n = WSHShell.RegRead (p)
errnum = Err.Number

if errnum <> 1 then

WSHShell.RegWrite p, 2, itemtype
End If

If n = 2 Then ' currently hidden

down = 9

'   WshShell.RegWrite p, 1, itemtype

End If

If n = 1 Then ' currently shown

down = 8

'   WshShell.Regwrite p, 2, itemtype

End If

WshShell.Run "RunDll32.exe shell32.dll,Options_RunDLL 7"
WScript.Sleep 500

WshShell.SendKeys "{TAB}"

'8 to hide
'9 to show
For i=1 to down

WshShell.SendKeys "{DOWN}"

Next

WshShell.SendKeys " {TAB}{TAB}{ENTER}"

Set WshShell = Nothing


After saving the VBScript, create a shortcut to the script someplace in your start menu. Right click the shortcut and assign the shortcut keys Ctrl - Alt - H.

Open up a folder and press Ctrl - Alt - H to show hidden files. Press Ctrl - Alt - H again to hide the files.

No comments: