如何使我的服务应用程序在启动时以管理员身份运行 [英] How do I make my service application be run as administrator at startup

查看:93
本文介绍了如何使我的服务应用程序在启动时以管理员身份运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在后台运行的应用程序,所以我把它作为服务应用程序。但问题是我的应用程序需要管理权限。

我正在将这个应用程序作为必须在所有时间运行(它适用于我学校计算机中的计算机,适合学生,如果没有,学生可以自由地做任何他们想做的事情。所以现在您知道为什么我希望我的服务应用程序以管理员身份运行。现在好了:

如果我只是告诉Windows在清单中以管理员身份运行它,它会显示一个弹出窗口,询问是否运行它。有些学生可能会点击否,这就是问题,我不希望弹出窗口显示。对于那些说不可能的人,我在我的计算机上安装了一个应用程序,它甚至没有显示弹出窗口(它在启动时运行,或者可能在此之前运行),我确信该应用程序是以管理员身份运行的。我的问题,如果你错过了它:

如何让我的服务应用程序在启动时以管理员身份启动?



我会感激任何帮助。

I have an application that works in the background, so I've made it as a service application. But the problem is that my application requires administrative rights.
And I'm making this application as a "must-be-running-all-times" (It is for computers in my school's computers, which are for students, and if it is not running, students will be free to do whatever they want). So now you know why I want my service application to run as administrator. Ok now to the point:
If I just tell Windows to run it as administrator in the manifest, it'll show a popup asking whether to run it or not. And some students might click on no, that's the problem, I don't want that popup to show. And for those who say it's not possible, I have an application installed in my computer which doesn't even show the popup (it runs at startup, or maybe before that), and I'm sure that that application is working as an administrator. My question if you missed it:
How do I make my service application start as administrator at startup?

I'll appreciate any help.

推荐答案

你的问题令人困惑。你说你写了一个服务应用程序。服务应用程序启动时无需任何人登录计算机。它们在Windows启动时启动,而不是在有人登录时启动。当有人登录时询问是否以管理员身份运行它时,根本不会出现界面。



您显然没有编写服务应用程序,而是编写了一个正常的Windows窗体应用程序,它是从注册表运行键开始的。这不是服务应用程序。运行Run键的应用程序将始终以登录用户身份运行。如果该用户没有管理权限,您的应用程序将无法启动。



你需要将此应用程序重写为实际的服务应用程序才能使其正常工作。您根本无法拥有任何用户界面,也无法与登录用户桌面进行交互。服务应用程序在用户永远不会看到的独立桌面下运行。
You question is confusing. You say you wrote a Service application. Service apps start without anyone logging into the machine. They start when Windows starts, not when someone logs in. There is NEVER an interface that appears when someone logs in asking whether to run it as an administrator or not.

You apparently didn't write a service application but a normal Windows Forms application that you're starting out of the registry Run key. This is NOT a service application. Applications running out of the Run key will ALWAYS run as the user that logged in. If that user does not have administrative permissions, your application will fail to launch.

You need to rewrite this application as an actual service application in order for this to work. You can not have any user interface at all and no interaction with logged in users desktop. Service applications run under their own separate desktop that the user never sees.


这篇关于如何使我的服务应用程序在启动时以管理员身份运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆