2

As can be seen from other questions across the Internet and right here on SuperUser (e.g. Keep programs from using My Documents), Windows users find it very annoying that programs decide for themselves to add their own folders to the user Documents folder.

The user's Documents folder, like her Music or Pictures folder, is for her personal files, to be managed and structured and organised in a way that makes sense to her alone. So many programs dump their files in here, it can quickly become impossible to find your own actual documents.

If you scour the Internet, and SuperUser, you will find the following varying advice, all of which are non-solutions to the question: How can I stop this from happening?

  • Move your Documents folder somewhere else, then create a new folder the system doesn't know is actually what you'll use for your documents. (No good: I want the system to know where I store my documents, for all the other times this is useful.)
  • Put all your actual documents inside a subfolder inside the Documents folder. (No good: why should I always have to dig one level in to get to my documents, and have to wade past all the spam folders at the main level?)
  • Manually clean up the folder periodically. (No good: that will break a lot of those programs.)
  • Various methods to prevent unauthorised folder creation. (No good: that will break a lot of those programs.)
  • Run programs in a VM. (No good: overkill for 99% of scenarios.)
  • Don't use those programs. (No good: I need to use those programs.)

Finally you may arrive at the solution I currently use, which I feel is the best of a bad lot:

  • (Optional: Move the offending folders somewhere else, then hardlink that location back to Documents.)
  • Hide the offending folders in Documents.

Yeuck!

(Just to take a simple example of why this style of solution is still inadequate: one should be able to point e.g. a Backup software straight at Users/Documents – or indeed, copy the whole folder – and know exactly what one is getting. Also, a lot of people need to keep "Show Hidden Files" on.)

I'm slowly arriving at a question! – this isn't just a rant! The final note is to point out that the reason this problem occurs is because programmers are lazy and dump files in a place they can be sure is user-writable – even though there are dedicated AppData folders available. Once this behaviour is coded in, only the developer can change it – and most won't.

So. There is only one possible solution I can imagine and it's this. Somehow, the Environment Variable that determines the location of User/Documents must be presented differently to specific programs. I've arrived at a question –

How could this be achieved?

1
  • 2
    Short answer, you cannot. If you do this, you break many things and programs simply won't install, with something like: Invalid path, or a nondescriptive error.
    – LPChip
    Aug 15, 2019 at 14:45

2 Answers 2

3

Unfortunately, there is no environment variable for the location of user documents.

This path is rather returned by an API function called SHGetKnownFolderPath that returns known folders identified by their KNOWNFOLDERID constants, which for the per-user Documents folder is the constant FOLDERID_Documents.

Therefore to change it for specific programs, one would need to write a program that would create a system-wide hook for SHGetKnownFolderPath and return the wanted value. I don't know of any such product.

I can see no other solution than changing the configuration parameters of the products in question to set a default save location. If they don't have such a parameter, the only action possible is to complain to the developer.

4
  • Thanks. Surely there is an environment variable that is read at least for the User folder, for AppData, things like that? Changing it, as you point out, is a different question! Aug 16, 2019 at 15:04
  • Unfortunately there isn't. This is stored in the registry, so modifying it will change it for all programs.
    – harrymc
    Aug 16, 2019 at 16:23
  • Could the registry be intermediated, interrupted, or temporarily adjusted? Aug 18, 2019 at 19:43
  • Perhaps it could, but this would affect all programs.
    – harrymc
    Aug 18, 2019 at 19:54
0

There's probably no one solution for all programs. For already installed software, as harrymc noted, the program may have settings you can modify or registry entries that can be edited. If you're concerned with folder creation during installation, I would guess that modifying the registry values for Personal and (if it exists) {f42ee2d3-909f-4907-8871-4c22fc0bf756}, found under HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders to point to another folder, i.e. 'C:\Users\\BadApps` would "trick" the installer into creating folders in that location. After installation, the values ould be restored to their normal paths. Simple scripts could be written to "toggle" these values if this is a frequent need.

Not the answer you're looking for? Browse other questions tagged or ask your own question.