25

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
  • Please provide Windows version.
    – TheSAS
    Oct 29, 2013 at 14:03
  • We're not a script writing service. What have you tried already? Where are you getting stuck? Oct 29, 2013 at 14:42
  • @TheSAS - sorry; I tagged it, but forgot to add it to the question. Fixed.
    – Ickster
    Oct 29, 2013 at 15:15
  • 3
    @techie007 - I edited the question to change the tone a bit. I'm pretty tired, so the question was written slopily. I certainly wasn't demanding that you write a script for me; I was assuming it was clear that I had no idea what command to use to modify the setting. I appreciate your criticism of my poor question, and tried to make it better, but I feel like the tone of you response is a little too close to RTFM.
    – Ickster
    Oct 29, 2013 at 15:30

7 Answers 7

25

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

11

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
  • That worked but required me to log out and log back into the server to see the change
    – rob
    Feb 18, 2016 at 13:54
  • 1
    Found a powershell command that that does it for you Stop-Process -processName: Explorer -force
    – rob
    Feb 18, 2016 at 14:00
  • Did not work for me wrapped in the function() but works fine taken out. Also did not have to logout nor Stop-Process. Just refreshed the Explorer window.
    – JoelAZ
    Apr 29, 2019 at 4:23
6

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
1
  • 1
    Worked on Hyper-V Server 2019. No need to log out or restart server. (Ran as Administrator)
    – leanne
    Sep 5, 2023 at 20:49
2

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
  • Link-only answers are considered a no-no due to possible future link-rot. Please include pertinent information directly in your answers. Oct 29, 2013 at 14:42
  • @techie007 Thanks for you comment, i added the code to the answer to make it pertinent.
    – Chake
    Oct 29, 2013 at 14:56
  • I'm not going to be using AutoHotKey, but I like the addition to refresh Explorer. Thanks.
    – Ickster
    Oct 29, 2013 at 16:08
1
  • 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 !

0

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

http://www.askvg.com/create-simple-script-to-show-hide-file-extensions-in-windows-xp-vista-and-7/

0

i found a super easy solution that works and does not need any programming skills. Plus works on ALL settings for explorer and not just one:

You can set the option in the GUI and then export a regfile. You can then just click on this regfile anytime to set all options at a later time (or new PC).

go to explorer view settings and set it up the way you want.

In my case it was: show file extensions, explorer tree following the opened folders and compact view.

HOW TO:

open regedit and navigate to: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]

select that node with the mouse so its highlighted then in regiedit select File->Export. a dialogue will ask for a filename (extension reg) and save it. This will export all set options to a single file.

whenever you want to activate your settings just double click on the reg file and instantly all is set.

just remember to backup your reg file before trying things!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .