User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 375,172 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,102 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 18989 | Replies: 6
Reply
Join Date: Sep 2006
Posts: 3
Reputation: neon123 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
neon123 neon123 is offline Offline
Newbie Poster

passing parameters in bat file

  #1  
Sep 30th, 2006
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Posts: 30
Reputation: sendoshin is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
sendoshin sendoshin is offline Offline
Light Poster

Solution Re: passing parameters in bat file

  #2  
Sep 30th, 2006
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
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: passing parameters in bat file

  #3  
Sep 30th, 2006
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)?
Reply With Quote  
Join Date: Sep 2006
Posts: 3
Reputation: neon123 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
neon123 neon123 is offline Offline
Newbie Poster

Re: passing parameters in bat file

  #4  
Oct 1st, 2006
Originally Posted by sendoshin View Post
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
Last edited by neon123 : Oct 1st, 2006 at 3:12 am.
Reply With Quote  
Join Date: Sep 2006
Posts: 30
Reputation: sendoshin is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
sendoshin sendoshin is offline Offline
Light Poster

Re: passing parameters in bat file

  #5  
Oct 1st, 2006
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
Reply With Quote  
Join Date: Sep 2006
Posts: 3
Reputation: neon123 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
neon123 neon123 is offline Offline
Newbie Poster

Re: passing parameters in bat file

  #6  
Oct 1st, 2006
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
Reply With Quote  
Join Date: May 2007
Posts: 2
Reputation: kiran_berry is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kiran_berry kiran_berry is offline Offline
Newbie Poster

Re: passing parameters in bat file

  #7  
May 9th, 2007
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 12:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC