Where can a service running under the "local service" account save its state
I have a windows service (actually a serviced component) implemented in native C++. I want to be able to run it using the NT AUTHORITY/LOCAL SERVICE account but I want it to be able to store some startup-state information somewhere. Is the开发者_如何学运维re somewhere that the local service account has write access to? As far as I can tell, the built-in accounts don't get home directories like normal user accounts do.
In Windows XP, the LOCAL SERVICE account does have a home directory in Documents and Settings. In Vista/7, the LocalService account (along with other SYSTEM accounts) stores its data (by default) in C:\ProgramData.
You can access the folder in C# like:
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
So I assume you would access it in a similar way in C++.
精彩评论