How to add dependencies to a windows service

2019-09-22 07:14发布

问题:

How to add dependencies to a windows service in InstallShield? My winservice depend on the two following services, so they must run before the service starts:

  1. COMSysApp
  2. SENS

Note: I have used InstallShield project to install my service and not windows installer class so i could not use the way that mr. Jerry.Wang suggested in his article.

EDIT:

How to add a dependency to SEN Service in installshield?

回答1:

If you have dependencies on other services, the ServiceInstall table has the Dependencies column to describe this:

This column is a list of names of services or load ordering groups that the system must start before this service. Separate names in the list by Nulls. If the service has no dependencies, then specify Null or an empty string. Use the syntax [~] to insert a Null. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.

For example, to require that the system start service1 and service2, before starting the service listed in the ServiceInstall column, enter service1[~]service2[~][~] into the Dependencies column. The identifiers service1 and service2 must either occur in the primary key of the table or be the name of the service that is already installed.

You must prefix group names with + so that they can be distinguished from a service name. To require that the system start service1 and at least one member of the ordering group MyGroup before starting the service listed in the ServiceInstall column, enter service1[~]+MyGroup[~][~].

Here is what InstallShield has to say about their representation of that table:

Services Settings

Enter any service or load-ordering groups that this service requires. The system attempts to start the dependent service or at least one member of the load-ordering group before starting this service.

Separate multiple dependencies with a comma (,).

You must precede the name of each load-ordering group with the SC_GROUP_IDENTIFIER—which is typically the plus sign (+)—so that the Service Control Manager can distinguish it from a service.



回答2:

I have solved it myself by adding the dependencies in ServiceComponent Wizard.