Currently failed audits etc are not dealt with very well.
I propose we change the
Code:
''''''''''''''''''''''''''''''''''''''''
' Audit the local domain, if requested '
''''''''''''''''''''''''''''''''''''''''
section code to something similar to below. This would mean each audit.vbs exitcode can be recorded (and infact the stdout, stderror if required). This can be then used to create the failed audit list.
Then audit.vbs can be updated so that different error codes are raised (i.e. WScript.quit(errorcode)) depending on the error. These can then be included in the failed audit file.
Any comments on the code/idea
Code:
Const maxThreads = 2
Const noOfProcessors = 7
Dim WshShell
Dim theThreads(), processResults(), threadNum
Dim i
Set WshShell = CreateObject("WScript.Shell")
redim theThreads(maxThreads,1)
redim processResults(noOfProcessors)
i = 0
Do While i < noOfProcessors
While getNextThread = -1
WScript.Sleep 1000
Wend
threadNum = getNextThread
if (not isempty(theThreads(threadNum,0))) then
'record exit code
WScript.echo "Process Number:" & theThreads(threadNum,1)
processResults(theThreads(threadNum,1)) = theThreads(threadNum,0).ExitCode
end if
set theThreads(threadNum,0) = WshShell.Exec("cscript audit.vbs computer" & i)
theThreads(threadNum,1) = i
i = i + 1
Loop
waitForThreads()
for i = 0 to UBound(processResults)
WScript.echo processResults(i)
next
sub waitForThreads()
Dim i
for i = 0 to UBound(theThreads,1)
while theThreads(i,0).status = 0
WScript.Sleep 1000
wend
WScript.echo "Process Number:" & theThreads(i,1)
processResults(theThreads(i,1)) = theThreads(i,0).ExitCode
next
end sub
function getNextThread()
Dim i
getNextThread = -1
for i = 0 to UBound(theThreads,1)
if (isempty(theThreads(i,0))) then
getNextThread = i
elseif (theThreads(i,0).status <> 0) then
getNextThread = i
end if
next
end function