Shell to cmd.exe

Posted on 2005-04-25
Last Modified: 2010-05-02
Hi Guys, I need to run a .bat file from my vb application.  The .bat file cantains a line of text 'copy %1 %2'. where 1 is a path to a bunch of html files and 2 is the results file..(this batch file runs fine with parameters being passed to it from dos)..  I need to run this .bat file from my vb application and pass some parameters with it..  The shell command only seems to let you run the file and not pass any parameters..  please can anyone help..


Question by:Delboy
    LVL 26

    Accepted Solution

    shell environ("compsec") & " /C c:\yourfullpathbatfile yourarg", 0
    LVL 6

    Assisted Solution

    do you not mean "comspec", instead of "compsec" ?

    essentially you are shelling the following string:

    CMD /C C:\path\to\my.bat bat_argument_1 bat_argument_2

    Environ("COMSPEC") gives the path to the command line exe, CMD.EXE, from the COMSPEC environment variable

    the /C switch argument to CMD means "/Carry out this command"

    ion your case the command is a bat file

    Author Comment

    Thanks for the answer EDDYKT (the typo did get me for a few minutes), and thanks to cjard for the explantion..

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now