Automate print document from "Adobe PDF virtual printer" with powershell

  acrobat, automation, powershell, windows

I need to print a word document from "Adobe PDF virtual printer" with PowerShell. I found the below code from the internet and it works properly. But my question is when running the code for the batch of the word document it prompt Save as dialog box. It not a practical solution for the automated environment. Please help me to change the code to save the converted documents in the same source path without prompting any dialog box.

$TextDocumentPath = "D:*.doc?"

$defaultprinter = Get-WmiObject -Query "SELECT * FROM win32_Printer WHERE default=$true"
$PDFprinter = Get-WmiObject -Query "Select * From Win32_Printer Where Name = 'Adobe PDF'"
$PDFprinter.SetDefaultPrinter()
Dir $TextDocumentPath | Foreach-Object { Start-Process -FilePath $_.FullName -Verb Print }
$defaultprinter.SetDefaultPrinter()

Source: Windows Questions

LEAVE A COMMENT