mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Continue if profile not found
This commit is contained in:
parent
fa13f3e1ed
commit
b71695ab9b
@ -298,22 +298,14 @@ def delete(name,
|
||||
|
||||
# Remove the User Profile directory
|
||||
if purge:
|
||||
# If the profile is not defined, get the profile from the registry
|
||||
if user_info['profile'] == '':
|
||||
profiles_dir = __salt__['reg.read_key'](hkey='HKEY_LOCAL_MACHINE',
|
||||
path='SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList',
|
||||
key='ProfilesDirectory')
|
||||
profiles_dir = profiles_dir.replace('%SystemDrive%', os.environ['SystemDrive'])
|
||||
user_info['profile'] = r'{0}\{1}'.format(profiles_dir, name)
|
||||
|
||||
# Make sure the profile exists before deleting it
|
||||
# Otherwise this will throw an error
|
||||
if os.path.exists(user_info['profile']):
|
||||
try:
|
||||
sid = getUserSid(name)
|
||||
try:
|
||||
win32profile.DeleteProfile(sid)
|
||||
except pywintypes.error as exc:
|
||||
(number, context, message) = exc
|
||||
win32profile.DeleteProfile(sid)
|
||||
except pywintypes.error as exc:
|
||||
(number, context, message) = exc
|
||||
if number == 2: # Profile Folder Not Found
|
||||
pass
|
||||
else:
|
||||
log.error('Failed to remove profile for {0}'.format(name))
|
||||
log.error('nbr: {0}'.format(number))
|
||||
log.error('ctx: {0}'.format(context))
|
||||
|
Loading…
Reference in New Issue
Block a user