0

Hi,
This seems like a really simple question.
Most of the time I choose to show extensions for known file types, but sometimes (most notably when renaming files by hand) it is convenient to hide them.
This is achived by checking the checkbox at:
Tools -> Folder Options -> View -> Hide extensions for know file types.

Now what I would like to do is write a really simple app which will change this for me instantly.
So maybe when I run the app once it enables the setting and when I run it again it disables the setting. Really simple.

I'm guessing there is a DWORD somewhere in the registry or something to that effect. How would I got about doing this programmatically?

PS. I would prefer to do this in C# if possible.

Thanks in advance,

5
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by tnjman
0

its not easy enough to just do it manually?

if i was making an application to do this i would use autohotkey or autoit to just basically do a macro...

0

Thanks for fast reply!

its not easy enough to just do it manually?

Yes, but it is is even easier to have a once click app in my taskbar. :)
Also, for files on the desktop, folder options are not immediately accessible.
Also, I like learning new things, and lastly, I have OCD.

if i was making an application to do this i would use autohotkey or autoit to just basically do a macro...

I would rather not use a third party app for such a simple task. I'm sure in the end it just comes down to changing a single value somewhere in the registry...

0

Woo, I figured it out. :)

Works perfectly (in XP anyway).

It really is this simple:

using Microsoft.Win32;
namespace ShowHideExtensions
{
	class Program
	{
		static void Main()
		{
			RegistryKey key =
				Registry.CurrentUser.CreateSubKey(
				"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced");

			if ((int)key.GetValue("HideFileExt") == 0)
			{
				key.SetValue("HideFileExt", 1);
			}
			else
			{
				key.SetValue("HideFileExt", 0);
			}
		}
	}
}

Problem is that it doesn't update instantly... you have to hit refresh (or close windows explorer and open it again).

I wonder if there's a way to force the OS to invalidate or something...

0

Surely you could acheive this with a simple .reg file on the desktop

Foz

0

Surely you could acheive this with a simple .reg file on the desktop

Foz

I have no idea how that works. Will look into it, thanks for the reply.

0

First off: NEVER **EVER* hide extensions for known files types!
That is HUGE security risk! It was a HUGE mistake for Microsoft to make that a default!
There is NEVER any reason to do so.
I cannot even see how "renaming files manually" would require it, or would make renaming faster??? What if you have file "games.exe" and file "games.bat" - there is no freaking way you would know WHICH is WHICH, if you have known extensions turned off.

REMEMEBER LoveLetter.txt (that had HIDDEN extension of ".EXE") and people CLICKED ON IT, because they thought it was just a TEXT FILE?!?!? It was "Loveletter.txt.EXE" - do I have to say DUUUUUUUHHH? I repeat: NEVER **** EVER **** disable known extensions!
That said, here are the reg settings to do what you want:

[Logged in as a particular user]
Below DISABLES, so you are NOT hiding.
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t REG_DWORD /d "0" /f

Below ENABLES, so you are ARE hiding.
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t REG_DWORD /d "1" /f

[for the ENTIRE PC, just add HKLM key, then it stays consistent, no matter what user]
NOTE: for HKLM changes, you MUST BE AN ADMIN

Below DISABLES, so you are NOT hiding.
REG ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t REG_DWORD /d "0" /f

Below ENABLES, so you are ARE hiding.
REG ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t REG_DWORD /d "1" /f

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.