• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

Shell to cmd.exe

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..


Regards,


Derek.  
0
Delboy
Asked:
Delboy
2 Solutions
 
EDDYKTCommented:
shell environ("compsec") & " /C c:\yourfullpathbatfile yourarg", 0
0
 
cjardCommented:
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
0
 
DelboyAuthor Commented:
Thanks for the answer EDDYKT (the typo did get me for a few minutes), and thanks to cjard for the explantion..
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now