Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, March 1, 2012 11:33 AM
Hi,
I have an C# application which runs while the user is logged in, and starts a Windows Service (again C#) when the user logs out. While the user is logged in, the application is able to write to a file location - this is created to hold information, and needs to be updated by both the application and the Windows Service (i.e @"C:\MyApp\App_Files\Info.xml"). However, when the user logs out and the Windows Service tries to update this file, it can't due to lack of permissions.
This may be easier that I thought, but I have been searching this and can't seem to find a way to do this. By the way, the service can read from the file fine, and if I specify a path in the MyDocuments folder (e.g. Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\MyApp\App_Files\Info.xml", then it is able to update the file, but I need to use this file path.
So, overall, how do I give permissions to allow a Windows Service to update a file in a specific path location?
Thanks,
Stephen
Stephen
All replies (2)
Thursday, March 1, 2012 12:06 PM | 1 vote
Hi Stephen,
I think you can run the command **services.msc ** and get the properties of your service . In the properties window of your service,go to LogOn tab there you can set under which logon you need to run that service. I think after you set an admin account over there this issue can be resolved.
Thanks,
Raneesh
ran
Thursday, March 1, 2012 4:36 PM
Hi Raneesh,
Thanks for your reply.
Yes, I looked at this before under properties of the service specifically to do something locally on one machine. However I just want each user to install the application, and have the Service automatically capable of updating this file path location i.e. not to have to get each user to set this on every machine. Also, by changing this from Network Service to a local account may cause other problems if it were possible to do this programmatically.
Stephen
Stephen