diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 673ac9e593..a7d1961325 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -68,16 +68,16 @@ def _get_process_info(proc): def _get_process_owner(process): owner = {} - try: - domain, error_code, user = process.GetOwner() + domain, error_code, user = process.GetOwner() + if not error_code: owner['user'] = user.encode('utf-8') owner['user_domain'] = domain.encode('utf-8') - if process.ProcessId in [0, 4] and error_code == 2: - # Access Denied for System Idle Process and System - owner['user'] = 'SYSTEM' - owner['user_domain'] = 'NT AUTHORITY' - except Exception as exc: + elif process.ProcessId in [0, 4] and error_code == 2: + # Access Denied for System Idle Process and System + owner['user'] = 'SYSTEM' + owner['user_domain'] = 'NT AUTHORITY' + else: log.warning('Error getting owner of process; PID=\'{0}\'; Error: {1}' - .format(process.ProcessId, exc)) + .format(process.ProcessId, error_code)) return owner