Merge pull request #30623 from twangboy/add_config

Added service.config function
This commit is contained in:
Colton Myers 2016-01-27 14:08:12 -07:00
commit 8b17c77d72

View file

@ -443,6 +443,125 @@ def create(name,
return not __salt__['cmd.retcode'](cmd, python_shell=False)
def config(name,
bin_path=None,
display_name=None,
svc_type=None,
start_type=None,
error=None,
group=None,
tag=None,
depend=None,
obj=None,
password=None,
**kwargs):
r'''
Modify the named service.
.. versionadded:: 2015.8.5
Required parameters:
:param str name: Specifies the service name returned by the getkeyname
operation
Optional parameters:
:param str bin_path: Specifies the path to the service binary file,
backslashes must be escaped
- eg: C:\\path\\to\\binary.exe
:param str display_name: the name to be displayed in the service manager
Specifies a more descriptive name for identifying the service in user
interface programs.
:param str svc_type: Specifies the service type. Acceptable values are:
- 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
- adapt: Service is an adapter driver that identifies hardware such as
keyboards, mice and disk drives
:param str start_type: Specifies the start type for the service.
Acceptable values are:
- 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
:param str error: Specifies the severity of the error if the service
fails to start. Acceptable values are:
- 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
:param str group: Specifies the name of the group of which this service is a
member. The list of groups is stored in the registry, in the
HKLM\System\CurrentControlSet\Control\ServiceGroupOrder subkey. The default
is null.
:param str tag: Specifies whether or not to obtain a TagID from the
CreateService call. For boot-start and system-start drivers only.
Acceptable values are:
- yes/no
:param str depend: Specifies the names of services or groups that must start
before this service. The names are separated by forward slashes.
:param str obj: Specifies th name of an account in which a service will run
or specifies a name of the Windows driver object in which the driver will
run. Default is LocalSystem
:param str password: Specifies a password. Required if other than
LocalSystem account is used.
:return: True if successful, False if not
:rtype: bool
CLI Example:
.. code-block:: bash
salt '*' service.config <service name> <path to exe> display_name='<display name>'
'''
cmd = ['sc', 'config', name]
if bin_path is not None:
cmd.extend(['binpath=', bin_path])
if svc_type is not None:
cmd.extend(['type=', svc_type])
if start_type is not None:
cmd.extend(['start=', start_type])
if error is not None:
cmd.extend(['error=', error])
if display_name is not None:
cmd.extend(['DisplayName=', display_name])
if group is not None:
cmd.extend(['group=', group])
if tag is not None:
cmd.extend(['tag=', tag])
if depend is not None:
cmd.extend(['depend=', depend])
if obj is not None:
cmd.extend(['obj=', obj])
if password is not None:
cmd.extend(['password=', password])
return not __salt__['cmd.retcode'](cmd, python_shell=False)
def delete(name):
'''
Delete the named service