Windows – Automatically print word document using bat file

batch filemicrosoft wordprintingwindows

Automatically print word document using bat file

"C:\Program Files\Microsoft Office\Office14\winword.exe" "D:/new/CABSC.docx" /mFilePrintDefault /mfileexit

using this bat file I am able to print one word document automatically.

But I have more than 100 word document with different name. Is that possible to call them here to print all the word document using this bat file.

Best Answer

@echo off
setlocal
set "winword=C:\Program Files\Microsoft Office\Office14\winword.exe"
for /f "delims=" %%a in ('
  dir /b /s "c:\path\docs\*.docx"
') do (
  "%winword%" "%%~a" /mFilePrintDefault /mfileexit
)

Used SET VARIABLE, wildcards inside DIR inside FOR.

Related Question