r/PowerShell • u/TGotAReddit • Jun 09 '26
Question Ignore publisher popup when opening file?
Hi,
A few months ago, I made a powershell script for my coworkers where you put some publisher files into a folder, run the script, and it opens the files and saves them as a pdf, and recloses them after.
Recently, one of their product keys went out of date and they are trying to get the expense approved for a new one but in the meantime, they still need to convert more files. They can do the conversions manually by opening the file, clicking the little X on the modal dialog box about the outdated product key, and going to Save As. Doing it manually though is not feasible when they convert hundreds of files every day. The script errors out due to the modal dialog box blocks the script from running.
Is there a way to suppress the modal dialog box from opening when the script opens the files or a way to close the modal dialog box once it opens?
2
u/SVD_NL Jun 09 '26
You can try getting the process handle, bringing it to the front, and sending a keystroke that closes the dialog box. This can be a bit inconsistent, as windows doesn't always like it when you try to focus on a specific window. You could try waiting for the process to start instead, because it should automatically be in the foreground.
2
u/[deleted] Jun 09 '26
[removed] — view removed comment