views:

37

answers:

1

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 there 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.

Thanks,

Martin

A: 

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++.

palswim
Thanks. That's exactly what I needed to know. The actual environment variable is called "ProgramData".
Pacman
...actually, I've done some more poking around and that's not the whole story. The ProgramData directory is available on Vista/7 (not XP) but the localservice and networkservice accounts also still have their home directories. These are now located under C:\Windows. The good old UserProfile environment variable points the way on XP and Vista/7.
Pacman