ServiceStartService succeeds, but returns -1

Windows XP SP3, IS 2009 Premier SP2, InstallScript project

I'm registering and starting a service in the OnMoved event handler. I set SERVICE_IS_PARAMS.nStartServiceWaitCount to 20 seconds, since the service can hang in certain situations. ServiceAddService succeeds (it adds and starts the service), but returns a -1 result. If I don't specify nStartServiceWaitCount, then everything is fine.

If I tell ServiceAddService not to start the service, and call ServiceStartService separately, then the Add succeeds, while the Start returns the -1. As before, the service starts, but the function returns -1 anyway.

Calling GetExtendedErrInfo directly afterwards gives me 1060 (The specified service does not exist as an installed service). What am I doing wrong?
Labels (1)
0 Kudos
1 Reply

Call ServiceGetServiceState after ServiceAddService

Hi, I have the same problem with my installshield 2016 and basicMsi project.

And my solution is call ServiceGetServiceState after calling serviceAddService, because sometimes the service will be service_start_pending state, but the serviceAddService return -1 this time, in fact the service is installed success.

Hope to help any one who is troubling with the same problem.
0 Kudos