Easiest way to print from XP/DOS.

J

jim-on-linux

This is the situation I'm in.

I've built a single file utility using py2exe. I
zip the dist directory and send it to the client.

For clients that use win95, win98 machines,
They unpack the zip file and run the exe.

The utility creates a text file that is sent to
the printer with the statement below.
os.system('type ' +FileName+ ' >prn'),
and the file prints.

But, from an xp machine if I try to print using
the same statement, I get a question on the dos
screen which reads something like this;
Which program authorized this operation?

Since I don't have an xp machine, the statement
above may not be exact, but you get the idea.

The question I have is, first is there any way to
work around the question asked by the xp machine
using python.

If not, I may have to register the package in xp,
if registering the utility the only way, which
package is the simplest to use.
Also, if the utility is registered in xp, will the
same statement send the file to the printer as it
does in win98.

jim-on-linux
 
L

Larry Bates

jim-on-linux said:
This is the situation I'm in.

I've built a single file utility using py2exe. I
zip the dist directory and send it to the client.

For clients that use win95, win98 machines,
They unpack the zip file and run the exe.

The utility creates a text file that is sent to
the printer with the statement below.
os.system('type ' +FileName+ ' >prn'),
and the file prints.

But, from an xp machine if I try to print using
the same statement, I get a question on the dos
screen which reads something like this;
Which program authorized this operation?

Since I don't have an xp machine, the statement
above may not be exact, but you get the idea.

The question I have is, first is there any way to
work around the question asked by the xp machine
using python.

If not, I may have to register the package in xp,
if registering the utility the only way, which
package is the simplest to use.
Also, if the utility is registered in xp, will the
same statement send the file to the printer as it
does in win98.

jim-on-linux

I don't get any such message on my XP Pro Service Pack 2 system
here using your method.

-Larry
 
J

jim-on-linux

Did you run from a file or type in from keyboard?

When the client runs the utility program the
output file is built but nothing prints and no
messages appear. When I typed from keyboard on an
xp pro at c:\, I got the message.

Is it possible that virus detector or some
self.defense software is interacting?
 
T

Tom Plunket

jim-on-linux said:
When the client runs the utility program the
output file is built but nothing prints and no
messages appear.

If the file has a '.txt' extension, you could try os.system'ing
"start <filename>", which'll make the file pop open with notepad (or
whatever happens to be associated with TXT files), from which the user
would need to press Ctrl-P to make it print.
Is it possible that virus detector or some
self.defense software is interacting?

Quite. I run firewall software on my PC that alerts me when a program
is trying to launch another program. The message that it gives is not
entirely unlike the one you gave me.

To diagnose further, you could have the victim send you a screenshot to
see what's really going on. With Outlook, it's as easy as hitting the
Print Screen button (when the message is visible) and pasting the
clipboard into an email. Alternatively, they paste into MS Paint, save
the bitmap somewhere, and mail that to you.

Good luck,
-tom!

--
 
T

Tim Roberts

jim-on-linux said:
Did you run from a file or type in from keyboard?

When the client runs the utility program the
output file is built but nothing prints and no
messages appear. When I typed from keyboard on an
xp pro at c:\, I got the message.

Is it possible that virus detector or some
self.defense software is interacting?

It is quite possible that they simply do not have a printer hooked up to
their computer's parallel port. If all of your printers are from network
shares, then the special file "prn" will not go anywhere.

Typing to "prn" is a dreadful way to do printing on Windows.
 
T

Tim Golden

jim-on-linux said:
The utility creates a text file that is sent to
the printer with the statement below.
os.system('type ' +FileName+ ' >prn'),
and the file prints.

But, from an xp machine if I try to print using
the same statement, I get a question on the dos
screen which reads something like this;
Which program authorized this operation?

Since I don't have an xp machine, the statement
above may not be exact, but you get the idea.

You might want to look at this for some more
conventional approaches to printing under
windows:

http://timgolden.me.uk/python/win32_how_do_i/print.html

Specifically, I think you want the second option.

TJG
 
J

jim-on-linux

Thanks,
The client is in a one printer office. If the
output file is opened with note and then sent to
the printer everything is fine but it defeats the
purpose of the utility. Also tried > lpt1 but
the same results.

I'm trying to find out if this was some change in
xp from previous versions, or is there something
abnormal going on. I'm trying to avoid setting
up an xp machine for one client.


jim-on-linux
 
J

jim-on-linux

Thanks,
However, using note to print is a problem. First,
because note adds a header( file name etc.) to
the printed output that is not acceptable. Next,
the number of files is 200 to 300 per day. The
idea of the utility is to eliminate the operator.

But, if you have a virus detector that stops the
operation then I think I may have to install the
program as opposed to unzipping and running the
exe file.
 
M

mensanator

jim-on-linux said:
Thanks,
The client is in a one printer office. If the
output file is opened with note and then sent to
the printer everything is fine but it defeats the
purpose of the utility. Also tried > lpt1 but
the same results.

This may not help, but it worked once for me
although I don't remember the exact circumstances.

If the printer is connected to the pc, give it a sharename,
such as \\mypc\hpprinter. Then do a redirect of an lpt
port to that sharename: net use LPT2: \\mypc\hpprinter.

This indirect routing through the network driver back to
the local hardware port seems silly, but it did fix a
program that couldn't directly access the hardware.
 
T

Tim Roberts

jim-on-linux said:
Thanks,
The client is in a one printer office. If the
output file is opened with note and then sent to
the printer everything is fine but it defeats the
purpose of the utility. Also tried > lpt1 but
the same results.

Is it a USB printer? Remember that "prn" and "lpt1" refer to the first
parallel port, not necessarily the first printer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top