I have a Deplhi based Windows Service that, on installation, parses some command line arguments. I want those arguments to be added to the services command line (ImagePath value on the registry) so that the service is always started with them.
How can I accomplish this?
I want the regedit look like this:
at registry key HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MyService
ImagePath = C:\Path\to\my\service.exe -some -arguments
Thanks
Update: The installation is done with >MyService.exe /install -some -arguments. Those arguments are the ones I want to persist in the command line.
Update: I found a solution by writing directly to the registry (see here), but I’d still like a more elegant solution, like using some TService property or something of that sort. Thanks!
Ok, after some research, I gave up on an elegant approach, and took the straight-forward path of writing directly to the registry.
To make things simple, I did this: I store the arguments I wanted to pass in variables on my TService. Then, I set the AfterInstall event to write directly into the registry (using a TRegistry object) the exact command line I wanted.
Not the elegant solution I was looking for, but it does the job.
Thanks for the other answers through!