Solved

Print XPS documents from command line.

Posted on 2010-08-13
3
2,787 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
  • 3
3 Comments
 
LVL 14

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 14

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 14

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now