Reputation: 91
I have a simple bit of code below which runs an exe successfully 98% of the time.
PowerShell waits for FineCmd.exe
to close using | Out-Null
.
Note: FineCmd.exe
runs FineReader.exe
However, sometimes FineReader.exe
displays a simple error message box which stops the for loop. Once the user manually clicks OK and closes FineReader.exe
, PowerShell continues with the for loop.
How can I get PowerShell to:
FineReader.exe
FineReader.exe
The entire code is below:
$path = "C:\OCR\process.txt"
$files = Get-Content $path
[System.Collections.ArrayList]$FPaths = $files
cd "C:\Program Files (x86)\ABBYY FineReader 12"
for ($i = $FPaths.count - 1; $i -ge 0; $i--) {
.\FineCmd.exe $FPaths[$i] /lang Mixed /out $FPaths[$i] /quit | Out-Null
$FPaths.RemoveAt($i)
$Date = Get-Date -Format g
Write-Host $i "Files to go at " $Date
$FPaths | Out-File $path
}
Upvotes: 1
Views: 348