How to Start a Windows Service with Specific Parameters?

0
3
Asked By GadgetGuru89 On

I'm trying to configure a Windows service to start with a specific command that includes parameters: "name of the executable" -l ipaddress:12345. I've been adding the -l ipaddress:12345 to the ImagePath in the registry entry, but it doesn't seem to work correctly—it starts, but not as expected. I've heard about the Parameters sub-key, but I haven't found enough info on how to use it properly. Any suggestions on how to get this working?

4 Answers

Answered By RegistryWizard42 On

It sounds like you might be misunderstanding how the Parameters work. The arguments needed for the service when it starts should actually be included in the ImagePath of your registry entry. Just make sure there aren't any extra quotes or anything quirky in your command. Here's a helpful link that explains it: [MS Docs](https://learn.microsoft.com/en-us/dotnet/api/system.serviceprocess.servicebase.onstart?view=net-9.0-pp).

TechyTommy01 -

I think the issue might be due to spaces in the path. If your path contains spaces, it could lead to issues unless it's handled properly.

Answered By MondayMood On

Turns out I was just checking the service's status wrong! I added the -l ipaddress:12345 to the ImagePath correctly, and it worked just fine. Just a case of Monday confusion!

Answered By NSSM_Enthusiast On

Have you considered using NSSM? It's a great tool for managing services and allows you to set parameters easily. Might be worth a try!

CuriousCoder77 -

I found that tool too; I'll definitely look into it!

Answered By ScripterJoe On

You could create a small script to handle this. Something like:

wm withdraw .
exec name-of-executable -l ipaddress:12345
exit

Then use Freewrap to wrap that script into an executable and put that in your registry. This way, it runs in the background when the service starts. Hope this helps!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.