Click to See Complete Forum and Search --> : to run a DOS Batch (.bat file) from a VB app


shalini
December 3rd, 1998, 05:20 AM
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 ????

Christopher
December 4th, 1998, 07:46 PM
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

christopher
December 4th, 1998, 07:46 PM
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