Simple solution
If the output path doesn't matter, you could try PDFCreator with the following commandline:
C:\Program Files (x86)\PDFCreator>PDFCreator.exe /NOSTART /PF"C:\test.doc"
- Per GUI you have to enable Use Auto-save and set a auto-save path once.
From now on, this path will be used every time you execute the command above - You have to set PDFCreator as your default printer
Tip:
Per GUI you can save your settings in a profile (.INI file) which can then be selected when you execute your command line. This way, you don't have to use Auto-save as default for every normal print (e.g. from Word or Excel)
PDFCreator.exe /NoStart /OptionsFile"C:\myprofile.ini" /PF"C:\test.doc"
Advanced solution
The advantage of the second solution is, that you don't have to set PDFCreator as your default printer and you have full control over the output file path and name
Install PDFCreator together with its COM module
Copy & paste this code to a textfile and save it as
Convert2PDF.vbs
Set PDFCreator = Wscript.CreateObject("PDFCreator.clsPDFCreator", "PDFCreator_") With PDFCreator ReadyState = 0 .cStart "/NoProcessingAtStartup" .cOption("UseAutosave") = 1 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveFormat") = 0 .cOption("AutosaveStartStandardProgram") = 0 DefaultPrinter = .cDefaultprinter .cDefaultprinter = "PDFCreator" .cClearcache .cPrinterStop = false .cOption("AutosaveDirectory") = WScript.Arguments(1) .cOption("AutosaveFilename") = WScript.Arguments(2) .cPrintfile cStr(WScript.Arguments(0)) c = 0 Do While (ReadyState = 0) and (c < 120) c = c + 1 Wscript.Sleep 250 Loop .cDefaultprinter = DefaultPrinter .cClearcache WScript.Sleep 200 .cClose End With Public Sub PDFCreator_eReady() ReadyState = 1 End Sub
You can execute your VBScript file from the command line with this syntax:
Convert2PDF.vbs "C:\input.doc" "C:\outputfolder" "outputfilename"
Personally I use a slightly different version where the input and output folder+filename stays the same. I created a shortcut in my shell:sendto
folder to easily convert files per right-click