I have a printer, an HP DeskJet 712C, that I cannot print to via the shell "print" command in Windows 7 or Windows XP. I think this is because this particular printer is a "software" printer, something like a "software" modem. I am, however, able to print from Word, Notepad, and other programs. Is there some command line utility that I can use to print text files from?
2 Answers
Try using the notepad command line switch /p? e.g.
notepad.exe /p "c:\test.txt"
/A <filename> open file as ansi
/W <filename> open file as unicode
/P <filename> print filename
/PT <filename> <printername> <driverdll> <port> print filename to designated printer
You can use PowerShell's Out-Printer
cmdlet:
Get-Content './myfile.txt' | Out-Printer
You can even specify the name of a printer to use a non-default one, like so:
'Hi!' | Out-Printer 'Send to OneNote 2016'
That lets me put the text Hi!
right into OneNote.
-
Hi @Ben N do you have any alternative command for older systems like windows 7 this command is working perfectly on 10– FathyJun 20, 2022 at 14:06
-
@Fathy I only know of printing features in PowerShell 5.1 and 7.x. It might be possible to install PowerShell 5.1, e.g. with this update package, but if that doesn't work you'll need to use a different program like circle's answer suggested.– Ben NJun 20, 2022 at 16:25
print -DLPT1
to no avail.