views:

41

answers:

2

I have some legacy application logic that sends files to an attached printer using a DOS copy command:

copy fileToPrint \myLocalComputerName\printerShareName

The problem is that even though the application is running on the computer that's physically attached to the printer since it's using a network "share" it requires the network be available. If the network isn't available DOS throws a network unavailable error.

How can I code this so I don't have the network dependency? (preferably without re-architecting the entire file based print logic)

+1  A: 

Does this work? (Old DOS trick)

type myfile.txt > prn

This should work if the printer in question is the default printer on the PC.

David Stratton
It's not the default printer. :-(
Jeff
OK. Sorry I don't have a better answer.
David Stratton
But, it looks like the same trick might work with LPT1. I'll check in the morning. Thanks for the idea.
Jeff
That didn't work directly, but I found that the print command did--for LPT1. However, that didn't work with my newer USB printer. However, found a solution (will post as separate answer.) Thanks for the this idea however--upvote!
Jeff
+2  A: 

Found the following article which uses a loopback network adapter to access the local share when the network is unavailable.

http://geekswithblogs.net/dtotzke/articles/26204.aspx

Jeff
+1. Very good. This is worth knowing.
David Stratton