Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install service with delphi?

Tags:

service

delphi

I want a small executable to install my service with the usual

path\servicename /install

I've tried running a simple shellexecute in a program with elevated rights,

ShellExecute(0, nil, 'cmd.exe','/C servicepath\servicename.exe /install', nil, SW_HIDE);

but the service doesn't install. I am not exactly a wiz with ShellEx so I suspect I have gotten it wrong; kindly show me the errors of my ways and possibly supply the correct shellexecute line

like image 291
Bjarke Moholt Avatar asked Oct 17 '25 23:10

Bjarke Moholt


1 Answers

The proper way to install a service from code is to call the Service Control Manager (SCM) API. The /install parameter supplied by Delphi service does a "standard" call to the SCM that usually is not the best one for most services. Today, very few services, for example, should run with LocalSystem privileges because it's too powerful.

like image 119
LDS Avatar answered Oct 20 '25 14:10

LDS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!