[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3451
  • Last Modified:

Print XPS documents from command line.

I need to know how to print XPS comments from command line. We are trying to create a code that will print xps documents that are in a folder. We are unable to find a way to send xps print documents from command line. ANy help would be great. Thanks.
0
cstallings
Asked:
cstallings
  • 3
1 Solution
 
Giovanni HewardCommented:
One method... requires converting to PDF. See: http://verydoc.com/xps-to-pdf.html

@echo off
xps2pdf.exe C:\in\*.xps C:\out\*.pdf
for /f "delims=?" %%f in ('dir C:\out\*.pdf /b') do (
	AcroRd32.exe /t "%%f" "\\servername\printername"
        del %%f
)

Open in new window

0
 
Giovanni HewardCommented:
If you have XPS Viewer installed... start "example.xps" -p  also works if installed and associated with XPS files.
@echo off
for /f "delims=?" %%f in ('dir *.xps /b') do (
	xpsrchvw "%%f" -p
)

Open in new window

0
 
Giovanni HewardCommented:
Here you go... all-in-one solution.

Requires Microsoft XPS Viewer
Requires KiXtart @ http://www.kixtart.org/binary/distrib/KiX2010_461.zip

@echo off

:: create kix script for print dialog
:: download from http://www.kixtart.org/binary/distrib/KiX2010_461.zip
>"%temp%\xpsprt.kix" echo sleep 1
>>"%temp%\xpsprt.kix" echo if setfocus( "print" ) = 0
>>"%temp%\xpsprt.kix" echo    $rc = sendkeys( "{enter}" )
>>"%temp%\xpsprt.kix" echo endif

:: print each xps file
:: requires xps viewer
for /f "delims=?" %%f in ('dir *.xps /b') do (
	call cmd /c start %%f -p
	kix32 "%temp%\xpsprt.kix"
)

Open in new window

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now