CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 1998
    Location
    USA
    Posts
    7

    to run a DOS Batch (.bat file) from a VB app



    I want to run a DOS Batch (.bat file) from a VB app. For this I'm using

    Shell() in VB. .BAT files can accept parameters.

    When I pass param, as it is, to .bat file, it runs fine. ie. :--

    RetVal=Shell("abc.bat xyz",vbHide) 'Here xyz is the param value

    But when I pass param using a var which has the value for param, it

    doesn't work ! i.e. :--

    RetVal=Shell("abc.bat ParamVar",vbHide) 'here ParamVar contains the

    value for param

    Is there any way (any Function) by which paramete(s) can be passed to a

    .bat file using variable(s) as in the second case above ???

    Is there any special char to put as prefix with the variable containing

    parameter value ????

  2. #2
    Join Date
    Nov 1998
    Posts
    23

    Re: to run a DOS Batch (.bat file) from a VB app



    Basicaly if i am reading this correctly, your mistake is

    sending the paramater out as a string rather than a variable string.

    try something like this


    var="c:\"

    retval=shell("dir "+var,0)


    where var is your paramater or variable, this must! always be outside the quotes unlike your previous attempt which was somthing like this..

    retval=shell("dir var",0)



    this is Wrong!


    hope this helps!?


    Christopher

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