Date: | February 5, 2014 / year-entry #34 |
Tags: | tipssupport |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20140205-00/?p=1863 |
Comments: | 24 |
Summary: | Another converse of How do I programmatically create folders like My Pictures if they were manually deleted? and Why do folders like "My Pictures" come back after I delete them? is How do I prevent folders like My Pictures from being recreated? Starting in Windows 7, there is a group policy called Disable Known Folders which... |
Another converse of How do I programmatically create folders like My Pictures if they were manually deleted? and Why do folders like "My Pictures" come back after I delete them? is How do I prevent folders like My Pictures from being recreated? Starting in Windows 7, there is a group policy called Disable Known Folders which lets you specify a list of known folders which should be disabled. If somebody tries to create a known folder programmatically, the call will fail with Note that this policy only blocks creation of the folder. If the folder already exists, then the policy has no effect. (You're locking the door after the horse has bolted.) |
Comments (24)
Comments are closed. |
I'm not sure what this setting being a group policy entails. Does it mean only an administrator can set it, and for the whole machine?
Medinoc,
Group policy has machine and user level policies. This is a user-level policy.
That'd be great. I can't wait to get rid of "My Documents" folder, whose actual name is "Junk that I didn't create".
These known folders are also crowding "This PC" folder in Windows 8.1. I'd look up group policy to get rid of them too.
Does this mean I can't create a folder named "My Pictures" or that I can't create a folder with "known folder ID" set to "My Pictures"? Or Both?
I used to avoid those My Something folders since Windows 95. But with Windows 7 and its Libraries I gave up this fighting against the system and began using them.
Gotta second Fleet Command's comment for this: the fact that Win8.1 deprecates Libraries in favor of the user directory-hosted Pictures/Music/etc. in the Open/Save dialogs is a huge pain (and one you seemingly can't resolve without disabling them in the Registry).
It's especially infuriating because File History is a legitimately good feature that depends on a feature that, for whatever reason, Win8.1 has chosen to de-emphasize.
Next week:
"A commenter recently emailed, wanting to know why they are suddenly receiving an error when attempting to programmatically create My Documents…"
If the policy "only blocks creation of the folder" why wasn't it called 'Disable Known Folder Creation'? Calling it 'Disable Known Folders' is bound to make people think it does something it doesn't.
A way to block creation of a folder that happens to have the same name as a known folder is to pre-emptively create a file that has the same name.
What? You can have a folder and a file with the same name.
Er, because you need to read the policy description? How lazy are we?!
> You can have a folder and a file with the same name
Really?
>echo. > test
>mkdir test
A subdirectory or file test already exists.
But if you poke around enough you can have Xx and XX. Good one to stick on a thumb drive to confuse people.
Whoops I take that back. I tested it with the "Pictures" folder but completely forgot I had the folder redirected to a different volume. LOL.
@Maurits: That sounds like a recipe for endless support calls along the lines of "I'm trying to save a picture, but I can't get into the "My Pictures" folder…"
[This refers to the creation of known folders. It has no effect on any other folders which happen coincidentally to have the same name as a known folder. -Raymond]
Which means that somebody who handled any error from looking up a known folder path by assuming what the default would be would thoroughly wreck this. (They'll also end up with a mess if it runs on an OS from the future where the path changed.)
Incidentally, the way to create & set path to user-level known folders (besides the API that would be disabled here) in Windows XP got published. Anyway who was silly enough to actually use this would probably find their code worked in Windows 7 (see roaming profiles for why this probably still works), but risks their code not working in any future version (support for Windows 9 and Windows XP will have no overlap). Assume default value is a *lot* safer. Bail out the task that required it is a better idea.
@benjamin: What? 8.1 disables Libraries? I don't understand why they would do that. Another reason to stick with Win7 as long as possible.
Known folders are not something I've ever thought about deleting or creating, and I couldn't find any mention of directory creation in the known folder API, nor did a search for the words "create a known folder programmatically" enlighten me, so could someone please point me at the appropriate documentation?
@Azarien: I had the opposite thought when upgrading to Win7.
"What? 7 has Libraries? I don't understand why they would do that. Another reason to stick with WinVista as long as possible."
@Neil
Please, PLEASE continue not thinking about it.
I'd also like people to stop thinking about deleting them.
There's no valid reason to do the latter, and the only real reason to do the former is because someone did the latter.
Circular technical support.
@Azarien
Libraries are not disabled… (At least when upgrading from 8.0)
The "access denied" issue that some of you guys point out is significant. The matter wanting to save the the file from Paint into My Picture is not serious in comparison to some of the items that programs create in My Documents folder. Here is a list:
confidentialfiles.wordpress.com/…/my-documents-i-am-framed
@Fleet Command
Some blogs are filled to the brim with nonsense and terrible advice… and misrepresentations of what dates on products mean.
Instead of disabling it, use windows' approach of replacing system dll files from the dllcache.
–> Use a watchdog tool which listens to file system events and deletes the junk folders. Works very well.