Set service to manual if disabled on start

This commit is contained in:
twangboy 2016-10-17 10:48:40 -06:00
parent c30656814d
commit 1e1ee786c9

View file

@ -157,7 +157,18 @@ def get_service_name(*args):
def start(name):
'''
Start the specified service
Start the specified service.
.. warning::
You cannot start a disabled service in Windows. If the service is
disabled, it will be changed to ``Manual`` start.
Args:
name (str): The name of the service to start
Returns:
bool: True if successful, otherwise False
CLI Example:
@ -165,6 +176,11 @@ def start(name):
salt '*' service.start <service name>
'''
# Set the service to manual if disabled
if disabled(name):
cmd = ['sc', 'config', name, 'start=demand']
__salt__['cmd.retcode'](cmd, python_shell=False)
cmd = ['net', 'start', '/y', name]
return not __salt__['cmd.retcode'](cmd, python_shell=False)