salt.modules.win_service

Windows Service module.

salt.modules.win_service.available(name)

Returns True if the specified service is available, otherwise returns False.

CLI Example:

salt '*' service.available <service name>
salt.modules.win_service.create(name, binpath, DisplayName=None, type='own', start='demand', error='normal', group=None, tag='no', depend=None, obj=None, password=None, **kwargs)

Create the named service.

New in version Beryllium.

Required parameters: name: Specifies the service name returned by the getkeyname operation binpath: Specifies the path to the service binary file, backslashes must be escaped

  • eg: C:pathtobinary.exe

Optional parameters: DisplayName: the name to be displayed in the service manager type: Specifies the service type, default is own

  • own (default): Service runs in its own process
  • share: Service runs as a shared process
  • interact: Service can interact with the desktop
  • kernel: Service is a driver
  • filesys: Service is a system driver
  • rec: Service is a file system-recognized driver that identifies filesystems on the computer
start: Specifies the start type for the service
  • boot: Device driver that is loaded by the boot loader
  • system: Device driver that is started during kernel initialization
  • auto: Service that automatically starts
  • demand (default): Service must be started manually
  • disabled: Service cannot be started
  • delayed-auto: Service starts automatically after other auto-services start
error: Specifies the severity of the error
  • normal (default): Error is logged and a message box is displayed
  • severe: Error is logged and computer attempts a restart with last known good configuration
  • critical: Error is logged, computer attempts to restart with last known good configuration, system halts on failure
  • ignore: Error is logged and startup continues, no notification is given to the user

group: Specifies the name of the group of which this service is a member tag: Specifies whether or not to obtain a TagID from the CreateService call. For boot-start and system-start drivers

  • yes/no

depend: Specifies the names of services or groups that myust start before this service. The names are seperated by forward slashes. obj: Specifies th ename of an account in which a service will run. Default is LocalSystem password: Specifies a password. Required if other than LocalSystem account is used.

CLI Example:

salt '*' service.create <service name> <path to exe> display_name='<display name>'
salt.modules.win_service.create_win_salt_restart_task()

Create a task in Windows task scheduler to enable restarting the salt-minion

CLI Example:

salt '*' service.create_win_salt_restart_task()
salt.modules.win_service.delete(name)

Delete the named service

CLI Example:

salt '*' service.delete <service name>
salt.modules.win_service.disable(name, **kwargs)

Disable the named service to start at boot

CLI Example:

salt '*' service.disable <service name>
salt.modules.win_service.disabled(name)

Check to see if the named service is disabled to start on boot

CLI Example:

salt '*' service.disabled <service name>
salt.modules.win_service.enable(name, **kwargs)

Enable the named service to start at boot

CLI Example:

salt '*' service.enable <service name>
salt.modules.win_service.enabled(name, **kwargs)

Check to see if the named service is enabled to start on boot

CLI Example:

salt '*' service.enabled <service name>
salt.modules.win_service.execute_salt_restart_task()

Run the Windows Salt restart task

CLI Example:

salt '*' service.execute_salt_restart_task()
salt.modules.win_service.get_all()

Return all installed services

CLI Example:

salt '*' service.get_all
salt.modules.win_service.get_disabled()

Return the disabled services

CLI Example:

salt '*' service.get_disabled
salt.modules.win_service.get_enabled()

Return the enabled services

CLI Example:

salt '*' service.get_enabled
salt.modules.win_service.get_service_name(*args)

The Display Name is what is displayed in Windows when services.msc is executed. Each Display Name has an associated Service Name which is the actual name of the service. This function allows you to discover the Service Name by returning a dictionary of Display Names and Service Names, or filter by adding arguments of Display Names.

If no args are passed, return a dict of all services where the keys are the service Display Names and the values are the Service Names.

If arguments are passed, create a dict of Display Names and Service Names

CLI Example:

salt '*' service.get_service_name
salt '*' service.get_service_name 'Google Update Service (gupdate)' 'DHCP Client'
salt.modules.win_service.getsid(name)

Return the sid for this windows service

CLI Example:

salt '*' service.getsid <service name>
salt.modules.win_service.has_powershell()

Confirm if Powershell is available

CLI Example:

salt '*' service.has_powershell
salt.modules.win_service.missing(name)

The inverse of service.available. Returns True if the specified service is not available, otherwise returns False.

CLI Example:

salt '*' service.missing <service name>
salt.modules.win_service.restart(name)

Restart the named service

CLI Example:

salt '*' service.restart <service name>
salt.modules.win_service.start(name)

Start the specified service

CLI Example:

salt '*' service.start <service name>
salt.modules.win_service.status(name, sig=None)

Return the status for a service, returns the PID or an empty string if the service is running or not, pass a signature to use to find the service via ps

CLI Example:

salt '*' service.status <service name> [service signature]
salt.modules.win_service.stop(name)

Stop the specified service

CLI Example:

salt '*' service.stop <service name>