Bjarke Moholt
Bjarke Moholt

Reputation: 323

Install service with 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

Upvotes: 4

Views: 13483

Answers (1)

LDS
LDS

Reputation: 346

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.

Upvotes: 5

Related Questions