Recently we posted a tutorial about creating script to show / hide hidden files and folders in Windows:
Create Simple Script to Show / Hide Hidden Files and Folders in Windows XP, Vista and 7
Today in this tutorial, we are going to share another similar script which can be used to show / hide file extensions in Windows.
This script when executed, checks the status of "Hide extensions of known file types" option and toggles its value. So if its set to hide file extensions, it changes the option to show file extensions and vice versa.
Simply copy paste following code in NOTEPAD and save the file with name "Show_File_Extension_On_Off.vbs" (including quotes):
FileExt = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt"
Set Sh = WScript.CreateObject("WScript.Shell")
St = Sh.RegRead(FileExt)
If St = 1 Then
Sh.RegWrite FileExt, 0, "REG_DWORD"
Else
Sh.RegWrite FileExt, 1, "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 "Hide extensions for known file types" 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:
This article was posted by VG in following section: Windows 7, Windows Vista, Windows XP.
If you enjoyed this article, you can subscribe to our RSS feed or free newsletter to get all new articles directly in your Inbox. Also check out our most popular articles and archive to read other interesting articles. If you have some news or tip to share, please send us.
anonymous
Who taught you Visual Basic scripting?
Scott
Requires administrative privilege, it seems. Please tell people who actually use Windows security how this can be done. (I use Windows XP as a Limited User; your script does not work.)
Scott
Requires administrative privilege, it seems. Please tell people who actually use Windows security how this can be done. (I use Windows XP as a Limited User; your script does not work.)
Scott
OK, my problem isn't with Windows security. If you can delete my first comment and skip this one also, that would be nice. Sorry about that.
However, F5 doesn't do anything no matter what the setting of that registry value. I'll submit a better comment to this article if/when I figure out the problem.
Scott
Something is fishy with my computer, but it's so strange it cannot apply to anyone else, so if you'd just delete my comments here (or everyone ignore them with my apologies), that would be great.
Apparently the F keys are being ignored on my XP system just now; F2 is as broken as F5 is. But the context menu (right click) refresh works just fine. Weird.
Nathan
I am by no means an expert on VBS scripting, but I have also done this by taking and modifying a script to toggle thumbnail display on or off. Therefore, it may seem weird to a VBS expert (e.g. some lines might be unnecessary), but for some reason it works very well for me, so I decided to share it.
======
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
WshShell.SendKeys("{F5}")
======
It also automatically refreshes Explorer.
Zach
Hey completely unfamiliar with scripts at this point...How can I specify certain folders to be hidden? Thanks!
aatkco
Worked before, now after months of leaving it and probably updating windows caused it not to work, how to remove it from the right click menu ?
scythe
why not use wscript.exe instead? it will prevent those pesky cmd.exe popup...