简体   繁体   English

从Windows服务读取当前的用户注册表和配置文件数据

[英]Read current user registry and profile data from windows service

I am working on a window service, from where I have to access users profile specific data from location Environment.SpecialFolder.UserProfile . 我正在开发一个窗口服务,从那里我必须从Environment.SpecialFolder.UserProfile位置访问用户配置文件特定的数据。 I have to also access user specific registry key from here HKEY_CURRENT_USER\\Software\\Microsoft\\ . 我还必须从此处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? 但是,想象一下网络管理员必须将其安装在1000台计算机上的情况吗?

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? 如果管理员输入密码,其他密码也可以使用吗?

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. 您可以通过在C:\\ ProgramData \\ Microsoft \\ Windows \\ Start Menu \\ Programs \\ Startup文件夹中放置快捷方式来实现。 It will work for all users on the PC. 它适用于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. 现在,您将拥有一个以用户特权运行的进程,并且只要用户会话正在运行,该应用程序就会运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM