Obtaining %appdata% from windows service [C++]

854 views Asked by At

As in the topic - is there any way to get currently logged user appdata environment variable?

In an application there is no problem to do that with SHGetFolderPath() or simply getenv("appdata") but in service these methods doesn't work. It runs as "SYSTEM" account.

I think that should be a way to obtain %appdata% using WMI but I'm not sure about that.

%userprofile% is the second point of interest by I handle it when I will get %appdata%.

1

There are 1 answers

2
MSalters On BEST ANSWER

From a service viewpoint, there's no such thing as "the" currently logged-on user. There might be zero, one or more. Furthermore, it generally indicates a design error if your service needs it. What is the real problem you're trying to solve?