开发者

How do I install a Windows Service programatically with additional args?

开发者 https://www.devze.com 2022-12-12 13:01 出处:网络
I\'m attempting to install a service via C# from an installer\'s custom action. I\'ve tracked most of the topics related to my problem on Stack-Overflow however I\'ve failed to find a solution to my

I'm attempting to install a service via C# from an installer's custom action.

I've tracked most of the topics related to my problem on Stack-Overflow however I've failed to find a solution to my problem.

The problem is : I need to pass additional arguments to my service, here's how it looks like in cmd.exe :

my_service -installMY_SERVICE_开发者_如何转开发NAME cmdLine="commands in here" auxCommands="aux commands in here"
net start "My Service (MY_SERVICE_NAME)"

It works if I do it from the command line however I fail to get it done in C# therefore I'm forced to ask for help

Regards


It sounds like you want to start a service via the command line with C# and pass in additional arguments. Process.Start has parameters for command line arguments. Give this a try

Process.Start("my_service", "-install MY_SERVICE_NAME cmdLine=\"commands in here\"" auxCommands=\"aux commands in here\");
Process.Start("net", "start \"My Service (MY_SERVICE_NAME)\"");


Would this be what you are looking for, to start a service from C#? The article here on CodeProject might do the trick?

Hope this helps, Best regards, Tom.

0

精彩评论

暂无评论...
验证码 换一张
取 消