Change method of the Win32_Service class
The Change WMI class method modifies a Win32_Service. The Win32_LoadOrderGroup parameter represents a group of system services that define execution dependencies. The services must be initiated in the order specified by the Load Order Group because the services depend on each other. These dependent services require the presence of the antecedent services to function correctly.
This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.
Syntax
uint32 Change( [in] string DisplayName, [in] string PathName, [in] uint32 ServiceType, [in] uint32 ErrorControl, [in] string StartMode, [in] boolean DesktopInteract, [in] string StartName, [in] string StartPassword, [in] string LoadOrderGroup, [in] string LoadOrderGroupDependencies, [in] string ServiceDependencies );
Parameters
- DisplayName [in]
-
The display name of the service. This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. DisplayName comparisons are always case-insensitive.
Constraints: Accepts the same value as the Name property.
Example, "Atdisk".
- PathName [in]
-
The fully qualified path to the executable file that implements the service, for example, "\SystemRoot\System32\drivers\afd.sys".
- ServiceType [in]
-
The type of services provided to processes that call them.
Value Meaning - 1 (0x1)
Kernel Driver
- 2 (0x2)
File System Driver
- 4 (0x4)
Adapter
- 8 (0x8)
Recognizer Driver
- 16 (0x10)
Own Process
- 32 (0x20)
Share Process
- 256 (0x100)
Interactive Process
- ErrorControl [in]
-
Severity of the error if this service fails to start during startup. The value indicates the action taken by the startup program if failure occurs. All errors are logged by the system.
Value Meaning - 0
Ignore. User is not notified.
- 1
Normal. User is notified.
- 2
Severe. System is restarted with the last-known-good configuration.
- 3
Critical. System attempts to restart with a good configuration.
- StartMode [in]
-
Start mode of the Windows base service.
Value Meaning - Boot
Device driver started by the operating system loader.
- System
Device driver started by the operating system initialization process. This value is valid only for driver services.
- Automatic
Service to be started automatically by the service control manager during system startup.
- Manual
Service to be started by the service control manager when a process calls the StartService method.
- Disabled
Service that can no longer be started.
- DesktopInteract [in]
-
If true, the service can create or communicate with a window on the desktop.
- StartName [in]
-
Account name the service runs under. Depending on the service type, the account name may be in the form of DomainName\Username or .\Username. The service process will be logged using one of these two forms when it runs. If the account belongs to the built-in domain, .\Username can be specified. If NULL is specified, the service will be logged on as the LocalSystem account. For kernel or system-level drivers, StartName contains the driver object name (that is, \FileSystem\Rdr or \Driver\Xns) that the input and output (I/O) system uses to load the device driver. If NULL is specified, the driver runs with a default object name created by the I/O system based on the service name, for example, "DWDOM\Admin".
You also can use the User Principal Name (UPN) format to specify the StartName, for example, Username@DomainName.
Windows 2000 and Windows Me/98/95: You cannot specify StartName in UPN format. - StartPassword [in]
-
Password to the account name specified by the StartName parameter. Specify NULL if you are not changing the password. Specify an empty string if the service has no password.
Note When changing a service from a local system to a network, or from a network to a local system, StartPassword must be an empty string ("") and not NULL.
- LoadOrderGroup [in]
-
Group name that it is associated with. Load order groups are contained in the system registry, and determine the sequence in which services are loaded into the operating system. If the pointer is NULL, or if it points to an empty string, the service does not belong to a group. Dependencies between groups should be listed in the LoadOrderGroupDependencies parameter. Services in the load-ordering group list are started first, followed by services in groups not in the load-ordering group list, followed by services that do not belong to a group. The system registry has a list of load ordering groups located at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceGroupOrder.
- LoadOrderGroupDependencies [in]
-
List of load-ordering groups that must start before this service starts. The array is doubly null-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Group names must be prefixed by the SC_GROUP_IDENTIFIER (defined in the Winsvc.h file) character to differentiate them from service names because services and service groups share the same namespace. 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 of the members of the group.
- ServiceDependencies [in]
-
List that contains the names of services that must start before this service starts. The array is doubly NULL-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Dependency on a service indicates that this service can run only if the service it depends on is running.
Return value
| Return code | Description |
|---|---|
|
Success |
|
Not Supported |
|
Access Denied |
|
Dependent Services Running |
|
Invalid Service Control |
|
Service Cannot Accept Control |
|
Service Not Active |
|
Service Request Timeout |
|
Unknown Failure |
|
Path Not Found |
|
Service Already Running |
|
Service Database Locked |
|
Service Dependency Deleted |
|
Service Dependency Failure |
|
Service Disabled |
|
Service Logon Failure |
|
Service Marked For Deletion |
|
Service No Thread |
|
Status Circular Dependency |
|
Status Duplicate Name |
|
Status Invalid Name |
|
Status Invalid Parameter |
|
Status Invalid Service Account |
|
Status Service Exists |
|
Service Already Paused |
Remarks
To change a service from a network service to a local system the StartName and StartPassword parameters should have the following values:
StartName = "LocalSystem" StartPassword = "" // - empty string, not NULL
To change a service from a local system service to a network the StartName and StartPassword parameters should have the following values:
StartName = "NT AUTHORITY\NetworkService" StartPassword = "" // - empty string, not NULL
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Namespace |
\root\CIMV2 |
|
MOF |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012