Configuring Services

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

Although services generally require little hands-on administration, there will be times when you need to reconfigure a service. For example, you might want to configure a service so that it starts automatically each time the computer starts. Alternatively, you might want to change the display name of a service, making the service and its function more obvious to administrators working in the Services snap-in. Management tasks such as these can be carried out using WMI.

The WMI Win32_Service Change method is especially useful for changing selected service properties on multiple computers throughout the enterprise. The Change method accepts 11 parameters, each representing a service property that can be modified. When passing these parameters, it is important to maintain the correct order. For example, PathName is the second parameter in the set of 11 parameters. To change this property, the new value for PathName must be the second item in the parameters passed to the Change method.

This means you must pass a value of some kind for DisplayName, the first item in the parameter list. If you do not want to change the current value of DisplayName, you can insert a comma for that value. For example, the following code changes just the PathName:

errReturn = strService.Change( , "c:\windows\services\new_name.exe") 

Because these single commas might be confusing to someone editing your script, you can instead insert the keyword Null or use a constant with the value Null. For example, you might create a constant named SAME_DISPLAYNAME, set it to Null, and then insert the constant into the parameter string as follows:

Const SAME_DISPLAYNAME  = Null errReturn = strService.Change _     (SAME_DISPLAYNAME , "c:\windows\services\new_name.exe") 

This makes it clearer that you are keeping the same display name and changing only the service path.

Table 15.3 provides a complete list of the service properties exposed to the Change method, as well as their ordinal position. The items that can be changed by using WMI represent only a subset of a service s full property set and do not include some properties, such as service description.

Table 15.3   Service Properties Exposed to the WMI Change Method

PositionProperty
1DisplayName Name of the service as displayed in the Services snap-in.
2PathName Full path to the service s executable file.
3ServiceType Type of service. Most services are type 4: services that run in their own process.

Valid services types include the following:

1 Kernel driver

2 File system driver

3 Adapter

4 Own process

5 Win32 shared process

4ErrorControl Action to be taken if a service fails during startup.

Valid error controls include the following:

0 Ignore

1 Normal

2 Severe

3 Critical

5StartMode Method used to start the service. Most service start modes are either Auto or Manual.

Valid start modes include the following:

  • Boot. This start mode is reserved for device drivers.
  • System. This start mode is reserved for device drivers.
  • Auto. Services automatically start each time the computer starts.
  • Manual. Services must be explicitly started, either by using the Services snap-in or by using a script.
  • Disabled. Services cannot be started until the start mode has been changed to either Auto or Manual.
6DesktopInteract Indicates whether the service can create or communicate with windows on the desktop. DesktopInteract can be set to either TRUE or FALSE. Interactive services must run under the LocalSystem account.
7StartName Account name under which the service runs. If not specified, the service runs under the LocalSystem account.
8StartPassword Password for the account name specified by StartName. Use an empty string ("") to specify no password and NULL to indicate that you are not changing the current password.
9LoadOrderGroup Load-ordered group to which the service belongs. When you start services as part of the computer start process, those that belong to load-ordered groups start first, services that belong to groups (but not load-ordered groups) start next, and services that do not belong to groups of any kind start last.
10LoadOrderGroupDependencies Set of load-ordered groups that must be running before this service can start.
11ServiceDependencies Services that must be running before this service can start.

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net