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
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).
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!
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!
I found that tool too; I'll definitely look into it!
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!
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.