Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to use Shell function in vb.net for printing?
Can anyone throw some light?
Shell accepts arguments(Path of exe file and status etc) but not file path of the file to be printed!
Posted

maybe this will help

use this command

Print Command[^]

via the

System.Diagnostics.Process Class[^]
 
Share this answer
 
Comments
PatilVL 17-Aug-10 13:57pm    
Thank you. Can you elaborate? for instance, to send file path as argument?
this is how I'd do it in C#

Process p = new Process();
p.StartInfo.FileName = "print";
p.StartInfo.Arguments = @"/D:COM3 c:\myFile.txt";
p.Start();
 
Share this answer
 
Comments
PatilVL 18-Aug-10 0:00am    
Thanks a lot. But still i have a problem
I am using laptop connected to printer via USB,
Following vb code is not working.
Dim p As New Process
p.StartInfo.FileName = "Print.exe"
p.StartInfo.Arguments = "/D:USB001 C: rash.txt"
p.Start()
I believe its not working because its USB port. Does it mean the above will work only with COM port or LPT?(by the way, when the code is run, print window flashes On and is immediately closes, but it doesnot Print.)
Thanks in advance.
I don't think the above will work as DOS doesn't know about USB ports - only serial and parallel I'm afraid. So you could do one of three things:
1) Emulate a network printer - see here:
http://geekswithblogs.net/dtotzke/articles/26204.aspx[^]
2) Download DOSPRN shareware - see here:
http://www.dosprn.com/[^]
3) If you at all possible don't write directly to the printer but use more up-to-date technology!

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900