Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Services are generally installed in one of two ways: either as a part of the operating system installation or by using an installation program provided by the service developer. However, some services, particularly those created in-house, might not have an installation program. In those instances, you can use the Win32_Service Create method to programmatically install services.
Despite the name, the Create method does not actually create a service; it merely installs an existing service. To use this command, you need to copy the service executable file to a computer and then use Win32_Service Create to install the service.
The Create method is similar to the Change method. In both cases, the properties of the service are passed as parameters to the method. As with the parameters used with the Change method, the order in which these parameters are passed is very important. You must pass the parameters in the order shown in Table 15.6.
A complete list of the service properties exposed to the Win32_Service Create method are shown in Table 15.6. For more information about each property, see "Retrieving Service Properties" earlier in this chapter.
Note
Table 15.6 Service Properties Exposed to the WMI Create Method
Position | Property |
---|---|
1 | Name Name of the service as stored in the registry. |
2 | DisplayName Name of the service as displayed in the Services snap-in. |
3 | PathName Full path to the service s executable file. |
4 | ServiceType Type of service. |
5 | ErrorControl Action to be taken should a service fail during startup. |
6 | StartMode Method used to start the service. |
7 | DesktopInteract Indicates whether the service can create or communicate with windows on the desktop. |
8 | StartName Account name under which the service runs. |
9 | StartPassword Password for the account name specified by StartName. |
10 | LoadOrderGroup Load-ordered group to which the service belongs. |
11 | LoadOrderGroupDependencies Set of load-ordered groups that must be running before this service can start. |
12 | ServiceDependencies Services that must be running before this service can start. |
Listing 15.22 contains a script that installs a service named DbService. To carry out this task, the script must perform the following steps:
This constant is used to specify that the service must run in its own process.
This constant indicates that the service does not interact with the desktop.
To create the service, include the following parameters:
You must specify a valid account name when installing a service. If the SCM cannot locate the specified account, installation fails.
If you specify an incorrect password, installation continues because the SCM does not verify passwords when installing a service. However, if the password is incorrect, the service fails when you try to start it.
Listing 15.22 Installing a Service
|
|
Send us your feedback | « Previous | Next » |