Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a command or script in Windows to print a file (various file types such as .doc .xls .txt .pdf) to the default printer?

As far as I know one usually has to execute the relevant application (Word, Excel, Notepad, Acrobat Reader) and ask it to print the file, but I could use a generic way of achieving this right now...

share|improve this question

I found this out through this article after being frustrated by Out-Printer.

The synopsis is that using Start-Process should do what you're looking for, if I understood the question:

Start-Process -FilePath "c:\somefile.pdf" -Verb Print

That will open the file with whatever the default program is and print to the default printer (note: can also specify a different printer). This leaves the program running, but...

Start-Process -FilePath "c:\somefile.pdf" -Verb Print -PassThru | %{sleep 10;$_} | kill

...will open, print, sleep for a few moments so the program actually has time to print, then kill it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.