cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
GuildOfCalamity
Level 3

How to configure service startup properties using scripting

I'm looking to see if there's a way to set a service to start as "Automatic (Delayed)" and the recovery options to restart the service on first failure. I have to be able to do this through the scripting language, I cannot use the GUI options; we have a complex scripting routine that I cannot deviate from or it will break the logic during the installer.

SERVICE_IS_PARAMS.dwStartType = SERVICE_AUTO_START;

I know there is the normal AUTO_START, but I don't see anything about auto delayed in the documentation.

 

Labels (1)
0 Kudos
(4) Replies
ch_eng2
Level 6

I realize this is not ideal, but the workaround we use is to run "sc" via command prompt in InstallScript after the service is created, via:

LaunchAppAndWait( WINSYSDIR ^ "cmd.exe", "/c sc config " + serviceName + " start= delayed-auto", WAIT | LAAW_OPTION_HIDDEN );

HTH

0 Kudos

Thanks for the info. I was actually using something similar, I call a batch file that contains...

Echo Configuring SERVICE_NAME for auto-start delayed...
SC config SERVICE_NAME start= delayed-auto

Echo Configuring SERVICE_NAME for auto-recover...
SC failure SERVICE_NAME actions= restart/1000/restart/1000/""/1000 reset= 0

0 Kudos
varul
Revenera Moderator Revenera Moderator
Revenera Moderator

0 Kudos

@varulDo you have examples of how to populate the szStartServiceArgs parameter so that the service will start Automatic(Delayed) with recovery options to restart the service after 1st & 2nd failures?

Unfortunately the documentation is lacking when it comes to examples of use.

0 Kudos