Click to See Complete Forum and Search --> : Parameters of Dos Batch file


chairyuan
June 13th, 2001, 11:40 AM
Here may not be the best place to ask, but I need call my VB in a dos batch file with a parameter. Does anyone know how to pass and how to use a parameter in a dos batch file (.bat file)?
Thanks alot

If you love it, you get it.
If you don't love it, you never get to it.

Iouri
June 13th, 2001, 11:55 AM
c:\YourVB.exe Param1

This Param1 you can read in VB using Command$

Iouri Boutchkine
iouri@hotsheet.com

chairyuan
June 13th, 2001, 12:13 PM
I was in a mass.
I've made an DQ_SEND.exe to let others call me in NT server.
And now they told me that they can not call me on server, they have to call my program in their client.
That's really a pain to set up all hundred PC to install my program and all the DataSource and DataLinks.
So I thought if that is posiable to let them call another program (like .bat), then the other program call my VB in server?

If you love it, you get it.
If you don't love it, you never get to it.

Spectre
June 13th, 2001, 04:18 PM
If what you need is to pass a parameter to the batch file and have the batch file pass that parameter on to your exe, set up the batch file like this:

[batch file contents]
My.exe %1
[end batch file contents]

The %1 in the batch file will be expanded to whatever parameter that you pass by the command processor. DOS batch file command line parameters are seperated by a space, so if your parameter must contain a space you will need to surround it with quotes.

Assuming your batch file is named My.bat and is in the same directory as the batch file (if you need it to be in a different directory you'll need to explicitly path the call in the batch file), to launch My.exe passing the parameter "wOOt!", you would use the line
My.bat wOOt!

Hope this helps.
Spectre

chairyuan
June 13th, 2001, 10:40 PM
Thanks! It's really helpful and it works perfact!

If you love it, you get it.
If you don't love it, you never get to it.