views:

215

answers:

2

Hello,

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

A: 

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.

tommieb75
I'm afraid there's no mention about passing additional arguments/start parameters to the service in there
Maciek
+1  A: 

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)\"");
Bob
That's one way to do it, however I need to do this programmatically
Maciek
That is a programmatic solution, that is valid C#
Bob
Well it works so I'll tag it as an answer - although this is not exactly what I was looking for
Maciek
What are you looking for?
Bob