VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. Member
    Join Date
    Jul 2002
    Location
    Up in yo' bitch.
    Search Comp PM
    How do I get visual basic to execute a .bat file? I just want to create a VB form with 2 combo boxes and an "OK" command button. I want the "OK" command button to execute a .bat file utilizing the inputs from the 2 combo boxes (the variable setting, I have no problem with).

    Mostly I need to know how to code execution of a .bat file in as simple terms as you can make it.
    Quote Quote  
  2. Free Flying Soul liquid217's Avatar
    Join Date
    Feb 2002
    Location
    United States
    Search Comp PM
    just use:
    shell "c:\path\to\script.bat", vbnormal
    replace vbnormal with however you would like it to run.
    If you are interested in capturing the output, take a look at the src to batchdemux, found on the link below.
    Quote Quote  
  3. Member
    Join Date
    Jul 2002
    Location
    Up in yo' bitch.
    Search Comp PM
    Dammit! Because I'm a new user with this, and have never attempted to call a .bat file with VB, I can't figure out how to get my input parms included with the command. I have two combo boxes: 1 list the source, the 2nd lists the destination. These values need to be entered concurrently. On a command line the input would appear as follows:

    c:\samples.bat source dest

    Can you give some help as to code the inputs? I thought I could figure it out, but I'm blank!
    Quote Quote  
  4. VH Veteran jimmalenko's Avatar
    Join Date
    Aug 2003
    Location
    Down under
    Search PM
    read your two combo boxes into variables:
    Code:
    var1 = combo1.text
    var2 = combo2.text
    then for your shell command:
    Code:
    Shell "c:\samples.bat " & chr(34) & var1 & chr(34) & " " & chr(34) & var2 & chr(34)
    The chr(34) adds double quotes. If you're using source and dest I'm assuming you're talking about paths to files or folders, and if they contain spaces then you'll probably need to use the double quotes around each var for the entire string to be recognised properly. When I'm interfacing with batch files, I get the batch file side of things water-tight first, to the point where everything works as designed from a command-line.

    Getting the right syntax in VB is the easy part

    I also use a msgbox to return the entire string I'm trying to use first just to make sure that it matches what I needed to type in manually previously.
    If in doubt, Google it.
    Quote Quote  
  5. Member
    Join Date
    Jul 2002
    Location
    Up in yo' bitch.
    Search Comp PM
    Thanks to all those who helped out. I solved most of my issues (except the whole not knowing VB worth a damn thing).
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!