SYNOPSIS
service
[
DESCRIPTION
The service command manages 10/2016/2019/11/2022/2025 services.
By default, it contacts the service manager on the local machine and
performs the action indicated by keyword on that service
manager.
You may specify either a hostname or a
domain-name using the
Options
-D domain-name-
locates the primary domain controller of domain-name, and requests that machine to perform the actions on behalf of the service command. service normally performs actions on the local system.
The
-D and-S options are mutually exclusive. -f -
stops (and restarts if appropriate) not just the specified service but also follows all dependents and stops (and restarts if appropriate) them as well. This option also implies the
-w option, that is, it waits until each dependent is handled before processing services they depend upon. With the restart keyword, it actually waits until the main service stops before it restarts the main service and then the dependents.This option is only usable with the restart and stop keywords.
- Note:
-
Using the
-f option may end up shutting down a lot of services, including some at low levels. Network and disk drivers may be shut down, preventing your machine from functioning properly until they are restarted. If any of the services get hung on shutdown due to busy processes, you may be forced to kill the service and possibly reboot your machine. For this reason, it is suggested that you use the-i option and select n (for no) if you do not know what all the listed services are for.
-i -
is similar to the
-f option except that it first lists the dependents and asks the user to confirm that all of them are to be stopped (and restarted if appropriate).This option is only usable with the restart and stop keywords.
-l -
displays long names. This option is only usable with the list and listdriver keywords.
-S hostname-
specifies the host machine that the service command requests to perform actions on its behalf. service normally performs actions on the local system. Optionally, hostname may be preceded by \\ or //.
The
-D and-s options are mutually exclusive. -s -
sorts output list. This option is only usable with the list and listdriver keywords.
-timeout seconds-
specifies the number of seconds that service has to complete the action before timing out and issuing an error.
-w -
waits for successful completion of the action and then returns. Normally, service returns as soon as the action begins.
The action taken by this option is automatically included in the performance of the
-f andi options and the restart keyword. This option is only usable with the stop, start, restart, pause, and continue keywords.
Keywords
- account [service-name]
-
displays the account for the specified service.
- continue service-name
-
restarts a paused service.
- dependents [service-name]
-
displays the list of services that depend on the specified service.
- depends [service-name]
-
displays the list of services on which the specified service depends.
- enum
-
displays status information on all non-driver services.
- enumdriver
-
displays status information on all driver services.
- interrogate service-name
-
requests that the service immediately updates its current status information to the service control manager.
- list
-
lists all non-driver services. By default, the short names of services are displayed unless the
-l option is specified. The services are listed in the order they are found unless the-s is specified. - listdriver
-
lists all driver services. By default, the short names of services are displayed unless the
-l option is specified. The services are listed in the order they are found unless the-s is specified. - locate [service-name]
-
displays the location of the specified service.
- pause service-name
-
pauses the specified service.
- query service-name
-
displays information on the service's status and current configuration.
- restart service-name
-
shuts down and restarts the specified service.
- start service-name [args ...]
-
starts the specified service. Arguments may be given which are passed to the service's
ServiceMain() function. - stop service-name
-
stops the specified service.
EXAMPLES
Used in conjunction with the registry command, the following script could be used to stop a service, make changes to registry parameters, then restart the service.
service -S '\\Server' stop MyService registry -S '\\Server' -s \ -k 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\MyService\Parameters' -n MyParameter -V dword:0x0 service -S '\\Server' start MyService
Note that you may not have permissions to manipulate a given service; you can use lsacl and chacl to examine and give permissions on the service.
lsacl -t s '\\Server\MyService' chacl -t s -g user:f '\\MyServer\MyService'
DIAGNOSTICS
Possible exit status values are:
PORTABILITY
Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.
AVAILABILITY
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
PTC MKS Toolkit 10.5 Documentation Build 40.