Home All Groups Group Topic Archive Search About

Text file printout in dos mode through VB.Net or DOS command from VB.Net

Author
8 Feb 2006 5:02 AM
Hardik Shah
Hi,

I am generating a text file through vb.net and I want to give facility to my
user to take DOS base (fast) printiout of it ,

or in other words,

I want to run DOS command from my application. i.e. TYPE C:\TEST.TXT >PRN ,
How can I ?

Regards,


Hardik Shah

Author
8 Feb 2006 6:13 AM
Cor Ligthert [MVP]
Hardik,

Using proces here one which is longer it can be one line as well.

\\\
Dim p As New Process
        Dim pi As New ProcessStartInfo
        pi.UseShellExecute = False
        pi.RedirectStandardOutput = True
        pi.Arguments = "www.google.com"
        pi.WorkingDirectory = "C:\windows\system32"
        'this for nt* computers
        pi.FileName = "ping"
        p.StartInfo = pi
        p.StartInfo = pi
        p.Start()
        Dim sr As IO.StreamReader = p.StandardOutput
        Dim sb As New System.Text.StringBuilder("")
        Dim input As Integer = sr.Read
        Do Until input = -1
            sb.Append(ChrW(input))
            input = sr.Read
        Loop
        MessageBox.Show(sb.ToString)
///

I hope this helps,

Cor
Author
8 Feb 2006 7:08 PM
Herfried K. Wagner [MVP]
"Hardik Shah" <har_sha***@hotmail.com> schrieb:
> I am generating a text file through vb.net and I want to give facility to
> my
> user to take DOS base (fast) printiout of it ,
>
> or in other words,
>
> I want to run DOS command from my application. i.e. TYPE C:\TEST.TXT >PRN
> ,
> How can I ?

Depending on the printer you may find the article below useful:

HOW TO: Send Raw Data to a Printer by Using Visual Basic .NET
<URL:http://support.microsoft.com/?scid=kb;EN-US;322090>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>