0

I am working on a window service, from where I have to access users profile specific data from location Environment.SpecialFolder.UserProfile. I have to also access user specific registry key from here HKEY_CURRENT_USER\Software\Microsoft\.

As per my knowledge if service is installed only as per user, then only I can access this above. But imagine a scenario where network admin have to install it on 1000 machine?

Is there a way service will work only for specific installed user profile and without such annoying installation? I am fine if service works for installed user, but installation becomes annoying.

If administrator enter his password will it work for other profiles as well?

crthompson
  • 15,653
  • 6
  • 58
  • 80
sunder
  • 1,803
  • 4
  • 29
  • 50
  • Since every process runs under a user account there is always "HKCU" and it should not be a problem to configure account at setup time and set registry key... but maybe you mean "current interactive user"? – Alexei Levenkov Sep 12 '13 at 05:15

1 Answers1

0

To my point of view you dont need a service if it is for users, a service runs background tasks that does not depend on users files at all.

If I were you I would write an application that starts when the user session starts (you could look at this ). You can achieve this by putting a shortcut in the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup folder. It will work for all users on the PC. You can configure the shortcut installation to this folder by creating an installation package.

Now you will have a process that runs with users privilege, and as long as the user session is running the application will run.

Community
  • 1
  • 1
codea
  • 1,439
  • 1
  • 17
  • 31
  • wow @codea, you read my mind. I was discussing same with my friend. But I want to make it user specific. Say if you installed it, it should work only for you account not other user account. Can I control that by making entry in specific user registry. – sunder Sep 12 '13 at 05:27
  • Instead you could install the startup shorctut here:C:\Users\%CurrentUser%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. There is an environment variable %appdata% that brings you to C:\Users\%CurrentUser%\AppData\Roaming so you could use something like that (not tested) Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) ,@"\Roaming\Microsoft\Windows\Start Menu\Programs\Startup") to get the directory and write there. You can even install you program in there. If you have a profile synchronisation in your business it will sync too.Hope this helps. – codea Sep 13 '13 at 20:49