CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    Pleez, Read This!!! Matter Important! "Printing in "DOS mode" using "Shell" -not happening, I wonder

    Hi

    [I had to repost it since I have not received any replies for my earlier post]

    I have a problem.

    Following is the code :

    Shell("c:\windows\command.com /c type " & App.path & "\matrix.txt >prn")

    where App.path is C:\XYZ

    when the above line is executed, the contents of "matrix.txt" is not printed on the printer. Instead, control just passes on to the next line.

    So, to find out why, I modified the line thus.

    Shell("c:\windows\command.com /K")

    The above command takes me to the "command prompt". Here, when I give the command "type c:\xyz\matrix.txt >prn", which is what the vbcode does, I get the message "file creation error".

    So, I have identified the problem. Can anyone tell me why this "File creation error" occurs, And how to solve the problem?

    Thanks for reading through.




  2. #2
    Join Date
    May 2000
    Location
    Nottingham UK
    Posts
    22

    Re: Pleez, Read This!!! Matter Important! "Printing in "DOS mode" using "Shell" -not happening, I wo

    As no one replied, I'll have a guess....

    Try two ">" instead of one, or try
    > LPT1

    and make sure theres a space either side of the >

    Scott.



    ---
    Freeware VB programs at http://net23uk.freeservers.com

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Pleez, Read This!!! Matter Important! "Printing in "DOS mode" using "Shell" -not happening, I wo

    First I send report output to the text file - TextFile.txt. Then I print from the text file

    Call PrintTextFile(TextFile.txt) - procedure call

    Public Sub PrintTextFile(ByVal sTextFile As String)
    'this sub shells to DOS and call nprint command to print the text file
    Dim sCommandString As String
    Dim sServerString As String

    'DOS command line -> nprint TextFile.txt q=OutqueueName s=ServerName nt nb ff

    sServerString = ServerName & " nt nb ff"
    sCommandString = nprint & " " & sTextFile & " q=" & OutQueueName & " s=" & Servername

    r = Shell("start.exe " & sCommandString, vbHide)
    End Sub


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Jun 2000
    Posts
    1

    Re: Pleez, Read This!!! Matter Important! "Printing in "DOS mode" using "Shell" -not happening, I wo

    Make sure you can print from command prompt without using any VB program.

    if using are Windows NT/98 on a network make sure you capture the printer in dos mode, like net use lpt1: \\servername\printername something like this. make sure your printer name is not more than 8 character. hope it helps.


  5. #5
    Join Date
    Jun 2003
    Location
    India
    Posts
    22

    Lightbulb Very Urgent printing Problem in Shell, Port

    Hi, Guyes

    First I use Shell command to send text print, but i got too problems, so i start send files copy to PRN ot LPT1.

    Case 1.
    Printer is installed on Windows 98,
    My program is running from Win 2000, I have shared the printer from 98 Pc, and Also set the Lpt port using net use command, it works fine.

    Problem 1:
    Printer is Installed on Windows 2000
    I am sending Print using above method to Win 98
    ( I have shared the printer, also Net Use for LPT1), Now in Program gives error File Not Found (I find which file, it says PRN is not found") and at the same time from DOS prompt If I used Copy FileName PRN or LPT1 then It works,
    But It not work through my Program.

    I also Tryed using OPEN Printer Port for Output it also gives the same Problem

    -------------------------
    Please Help in this case very fastly,
    Satish

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332
    You do not need to use Shell. Try this undocumented function:
    Code:
    Open "LPT1:" For Output Access Write As #1
    Print #1, "hello"
    Close #1
    You can also send printer escape codes.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured