sc.exe create service with arguments ...

Hello,

I am trying to create a service for an application (exe). To start exe , I have to pass args as followed -

Testapp.exe -conf "app.xml" 

Now, I want to create a service for this application , so that after machine restart , application will run by reading

configuration (app.xml).

I tried followed -

case 1) sc.exe create "Testapp"  type= own  start= auto  binPath= "C:\myapp\Testapp.exe -conf C:\myapp\app.xml" 


It didn't work. 

case 2) sc.exe create "Testapp"  type= own  start= auto  binPath= " \"C:\myapp\Testapp.exe\" -conf C:\myapp\app.xml" 

service is created but service doesn't start. Giving error as it not up in timely manner.

So, i want to know how to create service with passing agruments as well.

There are various pages says , you can pass the arguments as optionname etc. But there is no proper example about how

to pass such arguments.


Hi Limaye

The generic code to start a service with an argument is:

net start servicename /param0

So that would become:

C:\myapp\Testapp.exe\" /"C:\myapp\app.xml"

May I ask, is this an application/service you have created yourself or just some service you are trying to set up?
___________________________________________________________________

Power to the Developer!

MSI GV72 - 17.3", i7-8750H (Hex Core), 32GB DDR4, 4GB GeForce GTX 1050 Ti, 256GB NVMe M2, 2TB HDD

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 19, 2025 Views 3,706 Applies to: