The failed audit file is being overwritten each time audit.vbs is run, regardless of whether it's in the middle of a local domain/input file loop. I made the modification below to fix the problem. The only issue with my idea is that if you truly are only auditing a single machine then the failed_audits.txt file is not cleared. Maybe someone has a more elegant solution? Also, this file only catches audits that fail due to the computer not being reachable (IsConnectible()). Is there a way we get logging for other reasons? One other thing I noticed while debuging was that the possibility exists that two simultaneous audit.vbs processes could open/append to this file at the same time. For instance, if two consecutive computers are unreachable. I'm not sure what the best way to fix this is. Maybe putting the failure code in the main audit.vbs run, and child processes could exit with various errorlevels to indicate there was a problem?
I CHANGED: [code]Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists("failed_audits.txt") and (strComputer = "") Then Set objFile = objFSO.OpenTextFile("failed_audits.txt", 2) objFile.WriteLine objFile.Close Else Set objFile = objFSO.CreateTextFile("failed_audits.txt", 2) objFile.WriteLine objFile.Close End If[/code]
TO: [code]If strComputer = "" then Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists("failed_audits.txt") and (strComputer = "") Then Set objFile = objFSO.OpenTextFile("failed_audits.txt", 2) objFile.WriteLine objFile.Close Else Set objFile = objFSO.CreateTextFile("failed_audits.txt", 2) objFile.WriteLine objFile.Close End If End If[/code]
|