Solved

Print XPS documents from command line.

Posted on 2010-08-13
3
3,127 Views
Last Modified: 2012-05-10
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
Comment
Question by:cstallings
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 33434130
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
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 33434170
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
 
LVL 15

Accepted Solution

by:
Giovanni Heward earned 500 total points
ID: 33434282
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Printers have changed substantially in the last 30 or so years, not just in technical capabilities but in cost and usage as well.  Printers were originally used for interfacing with the operator, not necessarily for printing copy or pictures. In …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question