I have the following scenario:
I have a local printer connected to my Windows 8.1 PC and I would like to print several documents (files with the .txt, .pdf and .doc extensions), from the Command Prompt.
I have tried using the print command documented here. However, it doesn't work. I get no stuff being printed and an error message that says:
"Unable to initialize device DeviceName"
It doesn't matter if I specify the port where the printer is connected or the PC name followed by the printer name.
Is this command still supported in Windows 8.1? How can I solve this problem?
Best Answer
Here's a way to do it with VBScript. Based on an answer provided by Jobbo.
The catch is, you must have a program registered as the default handler. In other words, if you just type the name of a file from the command line, it should open in the appropriate program. For example, if you pass the argument of "file.pdf" you must have a PDF viewer installed. If you want to print a Word document, you must have Word (I think a viewer should work, but I didn't test that) installed.
One more thing, some programs leave a window open (Adobe Acrobat Reader X) after the document prints. You could add logic to the script to close it, but I'll leave that up to you.
To use, type in
cscript /nologo <name_of_script.vbs> <name_of_file_to_print>
where<name_of_script.vbs>
is the name of the program you save this under, and<name_of_file_to_print>
is the name of the file you would like to print. If the path contains spaces, enclose the argument in quotes.