I am creating a service that access a folder path:
string localAppDataFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Unfortunately, the folder returned is not:
C:\Users\mainuser\AppData\Local
... but:
C:\Windows\system32\config\systemprofile\AppData\Local
...instead.
mainuser
is the user that is currently logged in. Is it possible for service to launch a program that is placed in current users AppData\Local
? I am aware that you can go to Services-> Right click Properties-> Log on
and type in password and account name, but I am looking for a programmatic solution, ideally using sc create command
.
Alternatively, I can move all folders in interest to C:\ProgramData
and completely avoid current user. Is there a way to keep the files in users AppData\Local
and use programmatic solution without password?