CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2006
    Posts
    14

    execute batch files in the "Run" command line in a VB code

    Dear Sir,
    How can I execute batch files on the "Run" command line in a VB code?

    I have installed four printer in my computer:
    1-Acrobat Distiller
    2-Canon LBP-810
    3-hp LaserJet 1320 PCL 6
    4-Microsoft Office Document Image Writer

    I have problem with using “SHRunDialog” Function during selection of my default printer from one of my four installed printer in my computer with my VB code.
    I can not have any control in selecting default printer when I am trying to select “Canon LBP-810 “ printer or “hp LaserJet 1320 PCL 6” printer
    by using “SHRunDialog” Function in my VB code.
    I can not execute my favorite command : [rundll32 printui.dll,PrintUIEntry /y /n "hp LaserJet 1320 PCL 6"] in a new window and I can not define my favorite default printer by my VB code on the "Run" command line in a VB code.
    Please inform me that How can I use “SHRunDialog” Function for selecting “Canon LBP-810” or “hp LaserJet 1320 PCL 6” or other favorite printers as default printer (depend on my request, from on of my four printers) by my VB code?


    Sincerely

  2. #2
    Join Date
    Dec 2006
    Location
    Pune, India.
    Posts
    579

    Re: execute batch files in the "Run" command line in a VB code

    You can 'shell' command to execute your run command.

    or you can use Windows Scripting Host Object for selecting the default printer on your machine.

    or you can read it from windows registry.

    Which one you want?

  3. #3
    Join Date
    Dec 2006
    Posts
    14

    execute batch files in the "Run" command line in a VB code

    Dear Friend ,
    Can you instead of execute in the "Run" command line in a VB code the [rundll32 printui.dll,PrintUIEntry /y /n "hp LaserJet 1320 PCL 6"] this VB program ?

    Private Sub Command1_Click()
    Dim AA As String
    Dim RetVal
    AA = "hp LaserJet 1320 PCL 6"
    RetVal = Shell("rundll32 printui.dll,PrintUIEntry /y /n AA", 3)


    End Sub

    If you can please inform me HOW?

    I need a way for running [rundll32 printui.dll,PrintUIEntry /y /n "hp LaserJet 1320 PCL 6"] in the in the "Run" command with a VB code.

  4. #4
    Join Date
    Sep 2005
    Location
    Delhi, INDIA
    Posts
    237

    Re: execute batch files in the "Run" command line in a VB code

    Hi Camelia, I just wanna to know that do u want to run your command from "Run Dialog box" or from VB Shell command?

    Please clear it..!

    BTW...Hi again!
    I'M BACK AGAIN !!
    -------------------------------------------------------------------------
    enjoy the VB !
    If any post helps you, please rate that.
    Always try to findout the Solutions, instead just discussing the problem and its scope!

  5. #5
    Join Date
    Sep 2006
    Posts
    635

    Re: execute batch files in the "Run" command line in a VB code

    Hi .
    Code:
    dim NamePrinter  as string 
    NamePrinter = """hp LaserJet 1320 PCL 6"""
    RetVal = Shell("rundll32 printui.dll,PrintUIEntry /y /n " &  NamePrinter , 3)
    BTW:use tag code please.

  6. #6
    Join Date
    Dec 2006
    Posts
    14

    Re: execute batch files in the "Run" command line in a VB code

    Thank you very much. It is my solution.
    Sincerely,
    Camelia

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