Solved

Print XPS documents from command line.

Posted on 2010-08-13
3
2,912 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
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…

785 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