Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

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?

share|improve this question
Just for my education, why exactly would anyone do this? – Sickest Feb 20 '14 at 19:37
You don't specify if you're trying to print to a local or to a network printer. If thru a network printer, print won't work unless you map it to a local port. – JSanchez Feb 20 '14 at 19:53
@Sickest I imagine some kind of script that collects various system metrics and prints a physical document would require this command. – Michael Frank Feb 20 '14 at 20:03
@JSanchez I have mentioned the following: "I have a local printer connected to my Windows 8.1 PC". – Corporate Geek Feb 20 '14 at 21:10
My bad. Old age, my friend. Check the answer. Hope it works for you. – JSanchez Feb 20 '14 at 22:35

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.

Option Explicit

Dim shl, objFS
Dim fldr
Dim files,file
Dim file_to_print,wrk_folder

Set shl = CreateObject("Shell.Application")
Set objFS = CreateObject("Scripting.FileSystemObject")

if not wscript.Arguments.Count = 1 then 
    wscript.echo "Missing parameter!"
end if

file_to_print = wscript.arguments(0)
file_to_print = objFS.GetAbsolutePathName(file_to_print)
wrk_folder = objFS.GetParentFolderName(file_to_print) & "\"

wscript.echo "Argument passed: " & wscript.arguments(0)
wscript.echo "Absolute file path: " & file_to_print
wscript.echo "Work folder: " & wrk_folder & vbcrlf

if objFS.FileExists(file_to_print) then
    Set fldr = shl.Namespace(wrk_folder)
    Set files = fldr.Items

    For Each file in files
      If LCase(file.Path) = LCase(file_to_print) Then
      End If

end if

Set shl = Nothing
Set fldr = Nothing
Set files = Nothing
Set objFS = Nothing

share|improve this answer

The PRINT.COM command only works with text files. It will print anything that is pure text, such as .TXT, .INI, .BAT, etc.

If your program supports print to file, you can use the PRINT.COM command to send those files to your printer.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .