SQL Server Service
I am working on a Installation which requires the MS SQL Server 2000 service to be started if its not running or if its already running then it needs to be restarted. To achieve this I first get the MS SQL server service state using the "ServiceGetServiceState" function and then stop the service using the "ServiceStopService" function and then start it using "ServiceStartService" function. But sometimes this function does not work. It returns without starting the service. To overcome this problem I added these functions in a while loop waiting for 2 secs after executing "ServiceStartService" and then checking the Service State to see if it has been started. This solved my problem but then a strange problem started occuring. On some machines while executing the "ServiceStartService" in a loop the service never starts. The service status keeps on alternating between Starting and Stopped. This occurs on very few machines. While trying to figure out a solution I found that the problem occured on only those machines that were connected to a network cable. The problem got resolved automatically as soon as the network cable was detached from the machine.
I would like to know that why is this problem occuring. Why is the "ServiceStartService" function not working correctly when a machine is connected to a network?
I have already checked that the "ServiceStartService" function is not returning any error.
I would suggest you not to use InstallShield's Service-related functions at all. It is much better to call one of the following commands, using LaunchAppAndWait ():
- NET START/STOP
- SCM (Service Control Manager)
The syntax for the NET command is readily available on the DOS prompt. For SCM, have a look at this page. Alternatively, typing scm on the command line should also display a set of options.
Same problem, install hangs until network cable unplugged or adaptor disabled
someone must have figured this out by now?