views:

74

answers:

3

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?

+2  A: 

You are correct; there is no such folder.

You will need to create one yourself.

SLaks
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
@RCIX: What do you mean?
SLaks
@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
@SLaks: 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
A: 

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
Wrong; that's not writable by limited users.
SLaks
Well, that confuses me...
RCIX
Are you sure? I just checked on 7 and Public Documents is writable by Everyone.
jasonh
I just checked the Effective Permissions tab in Properties (also on Windows 7) and it isn't.
SLaks
Also, if you look up the description for FOLDERID_ProgramData, you'll see that it is for application data for *all users*. It's kind of the point that everyone be able to write to it.
jasonh
Something is messed up on your installation then, because mine shows Full Control checked off. I haven't touched that folder before.
jasonh
@jasonh: For what group?
SLaks
@SLaks: Everyone
jasonh
What folder? I don't see that.
SLaks
Odd, i checked Public Documents and SLaks is correct; no boxes are checked off when i input Everyone in the Effective Permissions security dialog.
RCIX
Maybe mine is the messed up one.
jasonh
Well thanks everybody for chiming in. Guess I'll use my Plan B :)
Stabledog
A: 

%ALLUSERSPROFILE%

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

BlueRaja - Danny Pflughoeft
Wrong; that's not writable by limited users.
SLaks