Quantcast
Viewing all articles
Browse latest Browse all 12583

Not able to get user 's app data folder when using Windows service

Hi,

I've a windows service which does following functionality

1. to watch closing events - I've used ManagementEventWatcher for this

2. when the event gets closed I've to update a xml file in the app data folder which is likeC:\Users\<user name>\AppData\Roaming\.

When I run as console or windows form, I'm able to get the user's appdata folder path; but when i use as windows service, I'm getting appdata path asC:\WINDOWS\system32\config\systemprofile\AppData\Roaming.

and when I used windowsidentity to get username from service, I'm getting empty string.

WindowsIdentity username = WindowsIdentity.GetCurrent();

or if i host the application as console or windows form in startup, there is the possibility for user to kill the process from task manager or they can run the exe many times. Thats why i've tried using the windows service.

Pls help me to get the user's appdata folder from windows service or atleast the current logged in username from windows service.



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>