delphi - Service does not start -


i created windows service delphi , used 2 method install, start , stop.

method 1

if install service using commandline

c:\myservice\serviceapp.exe /install 

it installed , can start , stop in service console.

method 2

but if install same service different name using sc e.g.

c:\windows\system32>sc create myservice binpath= c:\myservice\serviceapp.exe 

i see installed can not start service using service console

sc start myservice 

when query using sc , result follows

c:\windows\system32>sc query myservice  service_name: myservice         type               : 10  win32_own_process         state              : 2  start_pending                                 (not_stoppable, not_pausable, ignores_shutdown)         win32_exit_code    : 0  (0x0)         service_exit_code  : 0  (0x0)         checkpoint         : 0x0         wait_hint          : 0x7d0 

up till using /install want install same service multiple times different names, got idea of using post. (how install windows service command line specifying name , description?) can explain difference of behavior between /install , sc?

you have clashed bug in tservice implementation, see qc #79781. delphi not able start service if service name if different tservice.name.

however, can avoid limitation adjusting tservice.name before service started. 1 point tservice.oncreate event. need know real name of service, need pass argument service exe (adding binpath of sc create command).

create service:

sc create myservice1 binpath= "c:\myservice\serviceapp.exe myservice1" sc create myservice2 binpath= "c:\myservice\serviceapp.exe myservice2" 

adjust name:

procedure tmyservice.servicecreate(sender: tobject); begin   if (system.paramcount >= 1) , not charinset(paramstr(1)[1], switchchars)     name := paramstr(1); end; 

this rudimentary method of argument parsing, ok example. if first argument doesn't start / or -, assumes it's supplied name.

remark:

another limitation of tservice can't create services (using /install) arguments in command line, because uses paramstr(0) binpath.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -