How do I open a file (PDF specifically) in PowerShell and wait for the file to load (not close!) before continuing with the rest of the script?

0

I am using PowerShell to time how long files (mainly PDF) take to load. I have been using the com objects for other applications but it does not work when I use the following for PDF:

$app = New-Object -ComObject AcroExch.App
$PDDoc = New-Object -ComObject AcroExch.PDDoc

When using this I receive the following error:

"New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). At line:1 char:8 + $app = New-Object -ComObject AcroExch.App"

Another method I tried is this:

$pdf = Start-Process ((Resolve-Path <filepath>).Path) -PassThru

However, this command halts the script until the application has been closed which is not what I am looking for.

Can anybody help me by suggesting code that only waits until the application has fully loaded before carrying on with the rest of the script?

powershell
adobe
acrobat
asked on Stack Overflow Jan 13, 2020 by lpuchowski • edited Jan 13, 2020 by HAL9256

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0