简体   繁体   English

C#Windows Service以编程方式安装其他Windows服务

[英]C# Windows Service to programmatically install other windows services

I have a windows service application that i can install using sc.exe from command line. 我有一个Windows服务应用程序,可以从命令行使用sc.exe安装。 I'm trying to create another (manager) service that will check if i have a certain number of instances of the (worker) service running. 我正在尝试创建另一个(经理)服务,该服务将检查我是否正在运行一定数量的(工人)服务实例。 If not the manager will install the the application how many ever times required with a unique name each time (lets say add random number for now) 如果不是,那么管理员将每次以唯一的名称安装应用程序所需的次数(现在说添加随机数)。

I've tried the following 我尝试了以下

in the manager service have the following: 在经理服务中具有以下内容:
http://dotnetstep.blogspot.com/2009/06/programmatically-install-window-service.html http://dotnetstep.blogspot.com/2009/06/programmatically-install-window-service.html
but i keep getting "Cannot open Service Control Manager on computer '.'. This operation might require other privileges." 但我不断收到“无法在计算机'。'上打开Service Control Manager。此操作可能需要其他特权。”

i tried 我试过了
Installing Windows Service programmatically 以编程方式安装Windows Service
but i need to pass in parameters to the worker executable, as well as specify unique servicename and displayname 但是我需要将参数传递给worker可执行文件,以及指定唯一的服务名和显示名

Not sure what i'm missing here 不知道我在这里想念的是什么

Thanks 谢谢

Never mind. 没关系。 Turns out i wasn't running VS debug in admin mode. 原来我没有在管理员模式下运行VS调试。 turning that on got it to work 打开它使其工作

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

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