i need to pass two string parameters in bat file.....in visual basic 6

i am trying thgs like

Shell "N:\aa.bat abc bcd "

here abc and bcd are two string variables

but its not working...

wht shud do to pass parameters in bat file

Is the .bat file set up to take the arguments?

Assuming it is, there might be another thing you need to change. You said "abc" and "bcd" are string variables. Using Shell "n:\aa.bat abc bcd" passes the values "abc" and "bcd" to the batch file. Using Shell "n:\aa.bat " & abc & " " & bcd passes the contents of abc and bcd to the batch file instead. You may need to change this in your code.

If neither of these things lead to a fix, then I don't quite understand what's happening. Perhaps you could give us some more information?

Good luck!

- Sendoshin

Yeah, I'm not sure that the batch file is properly reading the data. A Simple test here (test.bat):

@echo off
echo %1
echo %2

and then the command line test.bat testing1 test2 produce the result of both parameters passed. Are you trying just to have the .bat file run, or are you trying to have it display the contents in a DOS window (which disappears when the app is done with it)?

Is the .bat file set up to take the arguments?

Assuming it is, there might be another thing you need to change. You said "abc" and "bcd" are string variables. Using Shell "n:\aa.bat abc bcd" passes the values "abc" and "bcd" to the batch file. Using Shell "n:\aa.bat " & abc & " " & bcd passes the contents of abc and bcd to the batch file instead. You may need to change this in your code.

If neither of these things lead to a fix, then I don't quite understand what's happening. Perhaps you could give us some more information?

Good luck!

- Sendoshin

thanks for ur reply

actually what i am trying to do is to pass parameters in vbscript file
im doing it through creating a bat file
iam modified the bat file to accept parameters

i jus need to pass parameter along with name of bat file to command prompt

the solution u gave Shell "n:\aa.bat " & abc & " " & bcd ....
when i use this ..it gives an error file not found


i jus need the correct code to send the bat file name along parameters


bat file contents are

wscript bookinst1.vbs %1 %2


i need to send a string values to the bat file

Hrm... It looks like you're setting up the .bat file to pretend it's the script. In that case, my example code is worthless, because that's VB code - not a call to a batch file.

Judging by your .bat file's contents, the .vbs script supports arguments. In this case, just running the script directly ( bookinst1.vbs abc bcd ) should work just fine.

If, however, you're creating the .bat file because the .vbs script doesnt work the way I just showed you, then the script itself isn't processing its arguments. In this case, you need to get the arguments from the command line into your script:

Dim Args
Args = WScript.Arguments

At this point, Args(1) is the first argument to the script, while Args(2) is the second argument, and so on. Be sure that the script is using the command line arguments properly, or it won't work.

- Sendoshin

i have modified the vbscript file to accept the parameters
if i run that bat file from command prompt along with passing parameters it works fine.

the problem arises when i execute that from vb ..
basically i need to send the name of bat file along with parameter to command prompt..so that it can execute

Hey I am also trying similar thing like this. can someone help me out.
I am running a batch file "batch.bat" Inside the batch file i am calling a VB exe file "test.exe". Within the VB I am trying to open a text file "new.txt".

I am stuck at passing an error message or some variable back to batch file "batch.bat" when the text file "new.txt" is not found.

I appreciate if someone can help me with this.

Thanks,
Kiran

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.