我有一个 powershell 脚本,它会自动打印 Foxit 文件夹中的所有 .pdf 文件。我将它设置为等到 Foxit 退出,直到脚本继续。每隔一段时间,即使 Foxit 已经退出,脚本也会暂停并等待。有没有办法让它在一定时间后超时?
这是我的代码:
Start-Process $foxit -ArgumentList $argument -Wait
Move-Item $filePath $printed[$location]
Add-Content "$printLogDir\$logFileName" $logEntry
我已经尝试过这里的建议,但它们似乎不起作用。例如,如果我这样做:
$proc = Start-Process $foxit -ArgumentList $argument
$proc.WaitForExit()
Move-Item $filePath $printed[$location]
Add-Content "$printLogDir\$logFileName" $logEntry
我得到:
You cannot call a method on a null-valued expression.
任何帮助将不胜感激。