Windows服务启动和停止没有管理员权限 [英] Windows Service start and stop without admin privileges

查看:4159
本文介绍了Windows服务启动和停止没有管理员权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何启动和停止窗口服务,而无需管理员权限?

How to start and stop window service without having admin privileges?

我的应用程序启动应该开始我就必须停止,一旦它被关闭的服务一样。我可以做到这一点使用服务控制器

My application launch should start my service same way it has to stop once it is closed. I can do this using "Service Controller "

我可以用管理员权限,但用于启动和停止服务不应该问管理员权限安装服务。

I can install the service with Admin privilege but for starting and stopping the service should not ask admin privileges.

谁能告诉我,我如何能做到这一点使用C#?

Can anybody tell me how I can achieve this using c#?

推荐答案

我已经发现的方式给予的权限启动/停止对非管理员用户的服务。我们可以提供一个组策略为我们的服务使这可能是启动/停止,无需管理员权限。 我发现了两个方法来实现这个任务。

I have discovered the way to give a permission to start/stop the service for non admin users. We can provide a group policy for our service so this can be start/stop without administrator privilege. I found two approach to achieve this task.

方法一:

  1. 创建从程序mmc.exe
  2. 控制台
  3. 创建空白的安全模板
  4. 创建一个安全数据库来存储策略信息
  5. 在改变,我们想给权限的服务权限,用户
  6. 在应用新的安全权限(我提到这个<一href="http://thommck.word$p$pss.com/2011/12/02/how-to-allow-non-admins-to-start-and-stop-system-services/"相对=nofollow>博客)
  1. Create the console from "mmc.exe"
  2. Created the blank security template
  3. Created a security database to store the policy information
  4. Change the service permission to the user which we want to give a permission
  5. Applied new security permission ( I referred this blog)

此方法工作完全正常,我已经创建了两个非管理员用户帐户在一个虚拟机,并​​从管理员帐户设置权限,我可以能够启动以及来自非管理员用户帐户停止服务。然而,这种做法是不是问题的一个完整的解决方案,它涉及到很多手动步骤。于是我开始寻找这个过程自动化。对这个结果,我发现这种方法2

This approach works perfectly fine, I have created two non admin user account in one virtual machine and set the permission from admin account, I could able to start and stop the service from both non admin user accounts. However this approach was not a complete solution for the problem, It involves lot of manual steps. So I start looking automate this process. Result of that I found the approach 2

方法二:       授予使用Subinacl.exe的权限,SUBINACL是一个命令行工具,使管理员,以获取有关文件,注册表项和服务的安全信息,并从用户传递这个信息给用户,从本地或全局组组,从域的域。

Approach 2 : Grant the permission using "Subinacl.exe", SubInACL is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.

我遵循了同样的例子创建两个非管理员用户帐户,并执行命令SUBINACL / SERVICE \域名\为MyService / GRANT =域名\ USERS =顶部,这将授予启动/停止该服务的用户。

I followed the same example of create two non admin user account and execute command SUBINACL /SERVICE \DomainName\MyService /GRANT=DomainName\USERS=TOP so this will grant the user to start/stop the service.

这篇关于Windows服务启动和停止没有管理员权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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