Hi
I run a batch file by VB6. The bach file need to pass a text file and a string (such as abc).
I used the following commands but I faced errors :

Shell "n:\aa.bat " & "c:\a1.txt" & "abc " , vbNormalFocus

Shell "n:\aa.bat " & " " & "c:\a1.txt" & " " & "abc" , vbNormalFocus

What is the command for doing that?

I'm not sure on what you are after. Do you require

1.) the instructions on how to accept the inputs with the batch file
Any arguments for the batch file are saved as % then a number. The first argument is always %1, the second is %2, the third is %3 etc

or

2.)How to add the batch file arguments on the end of the line while in VB?

I added this line in VB

Call Shell("c:\test.bat" & " " & "one two tree", vbNormalFocus)

and that worked fine

thank you very much for your attention

The batch file that I use, need to pass a text file.
In the ther other word after running batch file , the path of input data file (text file) should be entered.
I used the following command but It just run the batch file without reading data file.

Call Shell("c:\test.bat" & " " & "c:\x1.dat", vbNormalFocus)

What would be the command to run a batch file and read data file?

so you want to pass a varable (file path) to a batch file.

I can't see anything wrong with your code.

Lets see if the information is getting into the batch file, Create a new batch file and call it test1.bat and enter the following

@echo input 1 %1
pause

See what happens with that

This article has been dead for over six months. Start a new discussion instead.