Windows 7 and Common Application Data Folder in setup project
-
Wednesday, December 16, 2009 1:21 PMHi,
on Windows 7, VS2008, spcifying Common Application Data Folder as Custom folder as in http://social.msdn.microsoft.com/Forums/en/winformssetup/thread/56f98835-83f4-4b9e-8167-b37cb61a053c doesn't work.
The folder is created but in root of the system disk.
Any ideas what's wrong or how to get path to the compatible all users storage with read/write permissions?
Thx. Ondra
Ondřej Spilka
All Replies
-
Thursday, December 17, 2009 12:24 AMModeratorWhat's the exact path you get? If it's something like C:\ProgramData then that's correct (for example that's what I see on Server 2008). Are you sure you're not seeing this general access issue?
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/4353094a-1009-4ceb-87ad-8941dd3284ac
In other words, read/write to files CommonAppDataFolder has always been restricted. If your programs aren't manifested then even if you are administrator you can't read/write there without elevation, typically with a manifest.
Phil Wilson -
Thursday, December 17, 2009 8:26 AMHello Phil,
Yes might be.
But then my question is: what is the preffered way to store custom application data during setup, which will be read/write without elevation?
Easy question, complicated solution (as it seems to me :) )
I can elevate my app (uuh why? to tell the user I'm writing something to exact location which is designed to write app data? ok this is a different discussion about philoshophy :) ) and do the XCOPY. And I did it by this way and this should work on all operating systems I think.
But it's not a type of standardized solution, rather it's workaround.
Thanks
Ondřej Spilka -
Friday, December 18, 2009 12:03 AMModeratorOn UAC systems members of the Administrators group do not run with administrator privileges unless they elevate - by default they run as limited user. Therefore no programs can write to restricted locations on UAC systems unless they elevate somehow. On XP if you were an administrator you have administrator rights all the time, but not on UAC systems. So yes, you have a requirement that your app needs to run with administrator rights because it accesses restricted locations, and the way you do this on UAC systems is to elevate. So your existing code won't work on all operating systems because some are UAC and some are not. I'm not going to explain the whole deal about Vista, UAC, elevation etc and how it works or why it was done- you can read about all that. The bottom line is that UAC systems require programs to be elevated to perform privileged actions (like update file in CommonFiles) and that way to do that is with a manifest.
Phil Wilson -
Friday, December 18, 2009 6:56 AMHello Phil,
thanks for reply.
But back to the very first question :)
How do I configure path to ProgramData on windows7 in VS2008 setup project. As I wrote, when I specify custom folder and set the location to [CommonAppDataFolder], setup installs contents into root directory instead in ProgramData.
Thank you
Ondřej Spilka -
Friday, December 18, 2009 7:22 PMModerator
I don't know why this isn't working for you. When I create a test setup and install a file into CommonAppDataFolder (using the "Common" folder in the setup project's File System on Target Machine) it gets installed correctly into C:\ProgramData. Are you doing something else?
Phil Wilson- Marked As Answer by Aland LiModerator Monday, December 21, 2009 5:56 AM
-
Friday, December 18, 2009 7:27 PMModerator
ok, you're using a custom folder. I looked at that thread you referenced and it's incorrect. As I said, "Common" is the answer, and you can see that by selecting Properties Window on the Common folder it shows [CommonAppDataFolder].
Phil Wilson- Marked As Answer by Aland LiModerator Monday, December 21, 2009 5:56 AM
-
Thursday, September 23, 2010 2:38 PM
"Common" by itself is not an option in VS2008 setup projects "File System on Target Machine". If I select "Common Files Folder" it goes to "C:\Program Files\Common Files\AppName\...". In my application, I'm using "Environment.SpecialFolder.CommonApplicationData", which does translate to "C:\ProgramData\AppName\...".
I just need a folder into which to place files that can be non-admin user editable (by the application) and work across OSs from XP to Win 7 (i.e.: hardcoding a path into a Custom folder is out). What am I missing here? Thanks!
-
Thursday, September 23, 2010 7:33 PMModerator
You have to create the folder as a custom folder, and in its Properties set the DefaultLocation to [CommonAppDataFolder] - that's not in the drip down list but it is the propertyname for that ProgramData location.
Phil Wilson- Proposed As Answer by Alex_Ritchie Friday, November 04, 2011 3:08 PM
-
Thursday, September 23, 2010 7:49 PM
That did it, thanks! Now, would it have killed the makers of Visual Studio to put that in the darn dropdown lists? It's not like this is an unusual thing to do. It's proabably in VS 2010. Thanks again!
-
Friday, November 04, 2011 3:09 PM
BobDy - It's proabably in VS 2010.
Nope it is not I am afraid, had to find the solution by looking at this thread.


