ridgeway
asked on
CommonApplicationData folder access is denied in Vista to a Service
I have written a windows service that stores configuration settings in an XML file. I use to store the settings xml file in the program's folder however Vista's new security model does not allow this. The service runs for all users and should behave the same way for all users since it runs unattended (without a user logging on). After researching the folder to store shared user data in I found that I should be saving data here:
Environment.GetFolderPath( Environmen t.SpecialF older.Comm onApplicat ionData)
When my service runs howerver I get the exception:
Service cannot be started. System.UnauthorizedAccessE xception: Access to the path 'I:\ProgramData\settings.x ml' is denied.
My questions is - is this the correct directoy to store application specific data in and if so how do I use the Setup Project to give proper permission durring setup to this folder. If not, where should I write the settings for the service. Keep in mind that the service writes default settings if they do not exist and normally reads the setings on start. A seperate exe must write changes to the settings.
Environment.GetFolderPath(
When my service runs howerver I get the exception:
Service cannot be started. System.UnauthorizedAccessE
My questions is - is this the correct directoy to store application specific data in and if so how do I use the Setup Project to give proper permission durring setup to this folder. If not, where should I write the settings for the service. Keep in mind that the service writes default settings if they do not exist and normally reads the setings on start. A seperate exe must write changes to the settings.
Under what account does the service run?
ASKER
A user that has admin rights. Is is possible to prompt the installer to choose a user account at install time using a vs 2005 setup project? Does it have to run under the actual administrator on Vista?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I want to go with the more restrictive accounts and have chosen to store the data here:
Environment.GetFolderPath( Environmen t.SpecialF older.Comm onApplicat ionData)
I found that I could right click on "File System on Target Machine" in the Setup project to add this folder.
However, I have run into one big problem with this.
On XP 64 Environment.SpecialFolder. CommonAppl icationDat a does not return the (x86) part of the folder, how do I get around this?
Environment.GetFolderPath(
I found that I could right click on "File System on Target Machine" in the Setup project to add this folder.
However, I have run into one big problem with this.
On XP 64 Environment.SpecialFolder.