Celeb Glow
updates | March 06, 2026

Script to set "Hide file extensions"

I'm tired of the multi-step process to set my preferred folder options on every server to which I log on (Mostly Win2008, but also some 2012 and Win7 here and there). I'd love to be able to script the process, but unfortunately, I can't find any commands or extensions to do so for folder options.

There are several settings I'd like to change, but in particular, I'd like to set "Hide file extensions for known file types" to false. I figure that if I can do that, I'll be able to manage any additional settings on my own.

Methods that work on the vanilla command line would be preferred, but if there are commands in PowerShell, I'll use that.

4

6 Answers

You need to create two .reg files.

To hide extensions

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 1 /f

To show extensions

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f

Here is a Powershell version

function ShowFileExtensions()
{ Push-Location Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced Set-ItemProperty . HideFileExt "0" Pop-Location
}
function HideFileExtensions()
{ Push-Location Set-Location HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced Set-ItemProperty . HideFileExt "1" Pop-Location
}
3

I found this autohotkey solution at:How to write an autohotkey script to toggle the Show hidden files and folders setting?

This is especially nice because it also handles refreshing the explorer to make the change visible.

;------------------------------------------------------------------------
; Show hidden folders and files in Windows XP
;------------------------------------------------------------------------
; User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
; Value Name: Hidden
; Data Type: REG_DWORD (DWORD Value)
; Value Data: (1 = show hidden, 2 = do not show) #h:: RegRead, ShowHidden_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden if ShowHidden_Status = 2 RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1 Else RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2 WinGetClass, CabinetWClass PostMessage, 0x111, 28931,,, A Return
3

PowerShell one-liner to show file extensions (don't hide known extensions):

New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Value 0 -PropertyType DWORD -Force
  • Using any text editor, create a file unhide-known-ext.REG

  • inside, paste this content :

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
    "HideFileExt"=dword:00000000**
  • Save it

  • Double click this file and confirm OK.

comment :

  • dword:00000000 means show file extension
  • dword:00000001 means hide file extension

Good luck !

This is the only one that worked for me without any operations besides clicking the script file:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy