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.
+ Reply to Thread
Results 1 to 6 of 6
-
-
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. -
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! -
read your two combo boxes into variables:
then for your shell command:Code:var1 = combo1.text var2 = combo2.text
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.Code:Shell "c:\samples.bat " & chr(34) & var1 & chr(34) & " " & chr(34) & var2 & chr(34)
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. -
Thanks to all those who helped out. I solved most of my issues (except the whole not knowing VB worth a damn thing).
Similar Threads
-
Calling MediaInfo from Visual Basic to et video info
By SearchQuality in forum ProgrammingReplies: 18Last Post: 2nd Nov 2011, 07:36 -
visual basic code
By kudoshinichi in forum ProgrammingReplies: 1Last Post: 21st Jan 2009, 09:30 -
Visual Hub interlaced video to DVD
By chrjohns in forum MacReplies: 1Last Post: 29th Jun 2008, 22:42 -
Programming FFMPEG (Visual Basic)
By Ace-Of-Spades in forum ProgrammingReplies: 4Last Post: 9th Oct 2007, 07:18



Quote