2

SHGetKnownFolderPath() and its cohorts accept one of the constants defined here, returning the path to a directory.

I'm looking for one of these folders which is reliably writable by all users (including LocalSystem) on XP, Vista, and Windows 7... but I think I'm striking out. It appears that, in fact, there is no single location on the hard drive anymore where you can put a file and be assured that all users can write to it on all these OS versions, without fiddling the permissions first.

Is this true?

joe
  • 8,344
  • 9
  • 54
  • 80
Stabledog
  • 3,110
  • 2
  • 32
  • 43

3 Answers3

2

You are correct; there is no such folder.

You will need to create one yourself.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • If there's not already a folder you can write to already in all versions as a limited user, how do you do it without permissions fiddling on some version? – RCIX Apr 23 '10 at 00:33
  • 1
    @RCIX: that does seem to be a bit of a catch-22 at first, but I think SLaks is saying that the installation program (or something running as a non-limited or admin user for example) will need to arrange for a folder with the appropriate permissions for everyone to write to. – Michael Burr Apr 23 '10 at 00:41
  • without testing all possibilities, I can't prove you're right, but I suspect that is true. I can, of course, twiddle permissions, but was hoping to avoid having to do that. It's not a crisis. But as I was searching for this folder, I was struck by this realization: "there is really no public location on a Windows hard-drive anymore". It used to be anybody could delete the whole operating system with a typo! :) – Stabledog Apr 23 '10 at 00:48
0

One option seems to be FOLDERID_PublicDocuments, another could be FOLDERID_ProgramData. If there's a similar function you can use though to get a Documents type folder (for the user) that could work as well.

Edit: this blog post may help you.

RCIX
  • 38,647
  • 50
  • 150
  • 207
0

%ALLUSERSPROFILE%

This will not be writable by low-integrity processes or limited users, however.

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283