•
•
•
•
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
![]() |
•
•
Join Date: Sep 2006
Posts: 30
Reputation:
Rep Power: 2
Solved Threads: 1
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
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
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
•
•
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation:
Rep Power: 7
Solved Threads: 107
Yeah, I'm not sure that the batch file is properly reading the data. A Simple test here (test.bat):
and then the command line
@echo off echo %1 echo %2
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)? •
•
Join Date: Sep 2006
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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. UsingShell "n:\aa.bat abc bcd"passes the values "abc" and "bcd" to the batch file. UsingShell "n:\aa.bat " & abc & " " & bcdpasses 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.
•
•
Join Date: Sep 2006
Posts: 30
Reputation:
Rep Power: 2
Solved Threads: 1
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 (
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:
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
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
•
•
Join Date: Sep 2006
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: May 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Similar Threads
- passing parameters from a perl program to a c++ .exe file (Perl)
- Windows programming - C - Save file function (C++)
- running a .bat file in xp sp2 (Windows NT / 2000 / XP / 2003)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Need help
- Next Thread: end statement error happen in vbscript



Linear Mode