如何将可执行文件作为系统服务运行?

发布于 2024-08-26 02:47:15 字数 300 浏览 8 评论 0原文

我有一个用 .NET 2.0 编写的文件和数据分发应用程序,我编写的内容与 Steam 类似。

该应用程序需要在 Windows 7 中运行,并且需要能够运行和安装需要管理员权限的应用程序。但是,用户将没有管理员权限。

我的想法是将应用程序作为本地系统服务运行。我认为通过这样做,当用户不是管理员时,应用程序可以执行管理员权限操作(注册表编辑、启动应用程序等)。

我的假设正确吗?我需要采取哪些步骤才能将此应用程序安装为本地系统服务?

管理员将安装该应用程序,但它将由没有管理员权限的用户运行。

提前致谢!

I've got a file and data distribution application written in .NET 2.0 I've written similar to Steam.

This application will need to run in Windows 7 and will need to be able to run and install applications that require administrator rights. However the users will not have admin rights.

My thought was to run the application as a Local System Service. I figured by doing this the application could perform admin rights actions (registry edits, launching apps, etc) when the user isn't an admin.

Are my assumptions correct? What steps do I need to take to have this app install as a Local System Service?

An Administrator will be installing the application but it will be run by a user without Administrator rights.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠北森屋 2024-09-02 02:47:15

仅仅作为服务运行可能是不够的;通常,您不能只使用一个应用程序(尤其是交互式应用程序)并打开一个开关并将其变成一项服务。

该领域的一般模式是拆分您的应用程序:UI 像往常一样按需运行,具有用户的权限,并且还有一个运行 UI 与之通信的持久服务。一般来说,这种拆分是为了解决权限问题(例如您的问题)或即使在 UI 关闭时也能够执行操作。

在您的情况下,您可能无法使用该服务来启动应用程序,因为该服务通常无法访问登录用户的桌面。它也无法(轻松)访问注册表中的 HKEY_CURRENT_USER 配置单元,因为本地系统帐户与桌面用户帐户不同。

Just running as a service is probably not enough; you can't generally just take an app (especially an interactive one) and throw a switch and make it a service.

The general pattern in this area is to split your app: the UI runs on-demand as usual, with the rights of the user, and there is also a persistent service that runs that the UI communicates with. Generally, this split is done for permissions issues (like yours) or to be able to perform actions even when the UI is closed.

In your case, you might not be able to use the service to launch applications, since the service generally will not have access to the logged-in user's desktop. It also will not have (easy) access to the HKEY_CURRENT_USER hive in the registry, since Local System is a different account than the desktop user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文