@@ -119,9 +119,11 @@ def cleanup_after(smbshare, ip, text, bat)
119
119
simple . connect ( smbshare )
120
120
print_status ( "Executing cleanup on host: #{ ip } " )
121
121
psexec ( smbshare , cleanup )
122
- #if !check_cleanup(smbshare, ip, text)
123
- # print_error("#{ip} - Unable to cleanup. Need to manually remove #{text} and #{bat} from the target.")
124
- #end
122
+ if !check_cleanup ( smbshare , ip , text )
123
+ print_error ( "#{ ip } - Unable to cleanup. Need to manually remove #{ text } and #{ bat } from the target." )
124
+ else
125
+ print_status ( "#{ ip } - Cleanup was successful" )
126
+ end
125
127
rescue StandardError => cleanuperror
126
128
print_error ( "Unable to processes cleanup commands: #{ cleanuperror } " )
127
129
return cleanuperror
@@ -132,13 +134,18 @@ def cleanup_after(smbshare, ip, text, bat)
132
134
133
135
def check_cleanup ( smbshare , ip , text )
134
136
simple . connect ( "\\ \\ #{ ip } \\ #{ smbshare } " )
135
- if checktext = simple . open ( text , 'ro' )
136
- check = false
137
- else
138
- check = true
137
+ begin
138
+ if checktext = simple . open ( text , 'ro' )
139
+ check = false
140
+ else
141
+ check = true
142
+ end
143
+ simple . disconnect ( "\\ \\ #{ ip } \\ #{ smbshare } " )
144
+ return check
145
+ rescue StandardError => check_error
146
+ simple . disconnect ( "\\ \\ #{ ip } \\ #{ smbshare } " )
147
+ return true
139
148
end
140
- simple . disconnect ( "\\ \\ #{ ip } \\ #{ smbshare } " )
141
- return check
142
149
end
143
150
144
151
0 commit comments