VB Script is being deprecated. Powershell is a better scripting language.
This should work as long as you have the sequence that you posted. If you have jobs that start but do not finish, or you run multiple jobs at a time and have multiple start/stop records intermixed with each other, then you would need to modify the code to account for that.
$log = get-content c:\temp\x.txt
$Results = @()
foreach ($rec in $log) {
$data = $rec.split("]") # create array of TOD, user, and message
if ($rec.contains("Auto-running algorithm")) { # job start
$starttime = $data[0].replace("[","").trim()
}
if ($rec.contains("finished executing")) { # job end
$endtime = $data[0].replace("[","").trim()
$user = $data[1].replace("[","").trim()
$matches = [regex]::matches($data[2], "'([^']+)'") # pick off 'job name'
$jobname = $matches.Value
$results += [PSCustomObject]@{
JobName = $jobname
User = $user
StartTime = $starttime
EndTime = $endtime
}
# reset variables for next job.
$starttime = ""
$endtime = ""
$user = ""
$jobname = ""
}
}
$Results
$Results | Export-Excel -Path C:\temp\x.xls