standard print commands

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

standard print commands

Post by MigrationUser »

22 Apr 2015 11:48
npocmaka

Here I've tried to create a print tool , but as Simon pointed it will be not a universal as it wont work in different language settings.

Here are the print commands that I've found in the registry associated with some file extensions (not all have 'print' action) . Can be found HKEY_CLASSES_ROOT\extfile\shell\print\command or HKEY_CLASSES_ROOT\extfile\shell\printto\command

printto allows you to choose a printer and a driver , but again not all file types have it. The switch is ussualy /pt and accepts four arguments - <filename> <printername> <driverdll> <port>.Otherwise the default printer will be used.

Here they are (the %1 means the file name) . I think the list is pretty complete(ms office tools are not included):

plain text - Notepad /p "%1" (has /PT switch )

rich format text (.rft , .odt), plain text , word documents (.doc .docx) (if no MS OFFICE installed) - "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" /p "%1" (has /pt swith)

html,htm,svg - "%systemroot%\system32\rundll32.exe" "%systemroot%\system32\mshtml.dll",PrintHTML "%1" (no explicit /pt switch but the other arguments can be passed)

images , wdp - "%SystemRoot%\System32\rundll32.exe" "%SystemRoot%\System32\shimgvw.dll",ImageView_PrintTo /pt "%1" (no explicit /pt switch but the other arguments can be passed)

font files (ttf , ttc , pfb , pfm, oft )- %SystemRoot%\System32\fontview.exe /p %1

fax cover documents (.cov) - %systemroot%\system32\fxscover.exe /P "%1"

wdp file (Windows Media Photo ) , hdp (HD Photo) , font files (ttf , ttc , pfb , pfm, oft ) - rundll32.exe %SystemRoot%\system32\shimgvw.dll,ImageView_Fullscreen %1

emf (microsoft vector format) , images "%systemroot%\system32\mspaint.exe" /p "%1" (has /pt switch)

journal file (.jnt) - for XP/2003 - journal viewer is needed - https://web.archive.org/web/20160115031 ... x?id=20771 - "%ProgramFiles%\Windows Journal\Journal.exe" /p "%1" (has /pt switch)

images that Windows supports - jpg(jpeg,jpe,jfif,pjpeg),png,bmp(dib,ico),gif,tif(tiff)
Font files could be also truetype fonts.
not sure if fax cover is some kind of portable format or is something windows specific.

Other Printing commands

Print - sends info to PRN port.I had never succeeded to do anything with this command .How a printer can be associated with PRN port (https://filext.com/faq/print_from_prn_file.html) ?

TsWpfWrp.exe <PrinterName> <XPSFile> - for XPS files

PRINTBRM - part of Windir%\System32\spool\tools

Net Print - does not look convenient.

Edit - a little bit more info about XPS - successor of EMF files , similar to PDF and windows/ms propriety.For XP can be downloaded XPS pack ( https://web.archive.org/web/20151223105 ... x?id=11816) comes also with newer versions of Internet Explorer (I think 7) and also IE is capable to save a webpage in XPS format ready for printing. So the only chance to see a machine without TsWpfWrp is a windows XP/2003 with internet explorer 6. I think it requires .net framework.

EDIT : some text files extensions that are by default associated to Notepad as printing tool - .js,.jse,vbs,.vb,.txt,.reg,.ini,.wsf,.wsh,.csv,.xml , .log , .scp , .wtx

EDIT : For the MS Office files viewers can be used with /P switch

EDIT: shimgvw.dll has the following functions that can be used for printing:

ImageView_Fullscreen
ImageView_FullscreenA
ImageView_FullscreenW
ImageView_PrintTo
ImageView_PrintToA
ImageView_PrintToW
ImageView_fullscreenW

Last edited by npocmaka (22 Apr 2015 16:27)

----------------------------

#2 22 Apr 2015 19:09
npocmaka

some tools capable of printing:

printui.exe (has a lot of command line options that I need to check , not sure if it comes with winxp)
xpsrchvw.exe (the thing that comes with xps toolkit for XP/2003 .Prints xps files)
write (same as wordpad)

----------------------------

#3 22 Apr 2015 20:18
Simon Sheppard


A few commands like PRINT are only really useful with LPR print queues/plain ASCII
This page has more
https://ss64.com/nt/syntax-printing.html

The Print Management Cmdlets have a lot of potential for more complex tasks
https://docs.microsoft.com/en-us/powers ... ver2019-ps

----------------------------

#4 23 Apr 2015 21:04
npocmaka

it's possible use print command with network printer: https://web.archive.org/web/20150325054 ... /kb/314499

I couldn't achieve this with software pdf printer.

It's (almost) possible print command to be used for copying:

Code: Select all

@echo ###########>printable.txt
@print /d:localfile printable.txt
But there's one ♀ [0xFF] at the of the localfile.

Using print to print to console also has surprising behavior

Printing to file/from file works even trough UNC paths.
For me worked on Win7 and Win8 but didn't work on XP (don't if its because some not started service or there's some other reason)

Though print look like pretty outdated command.

----------------------------

#5 25 Apr 2015 09:03
npocmaka

Found why I was not able to PRINT to file on XP

To print to file in XP you need already existing file (and always append the content).On 7 and above you can print only to non-existing file.

PRINT adds page break/<FF> at the end of the affected file.May be this is something worth to be added to the print help page.

----------------------------

#6 25 Apr 2015 20:14
Simon Sheppard
npocmaka wrote:

PRINT adds page break/<FF> at the end of the affected file.May be this is something worth to be added to the print help page.
Done
Post Reply