简体   繁体   中英

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. 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
but i keep getting "Cannot open Service Control Manager on computer '.'. This operation might require other privileges."

i tried
Installing Windows Service programmatically
but i need to pass in parameters to the worker executable, as well as specify unique servicename and displayname

Not sure what i'm missing here

Thanks

Never mind. Turns out i wasn't running VS debug in admin mode. turning that on got it to work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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