Make .bat and .vbs work together!

scgryan@gmail.com

Beta member
Messages
2
I have a program and i like the batch format but i want for the user to input some numbers in the friendly vbs format. Is there any possible way to send data from a .vbs file to a batch file? If not is it possible to make a batch popup? Or maybe running vbs code in a batch file?
THANKYOU IN ADVANCE


Sent from my iPhone using Computer Forums
 
A batch file is a set of commands. You will not be able to insert data that way. Try C#, and learn your way around RAM info.
 
you can send "arguments" to any file (including batch files)
to invoke a batch file from vbs use code like this:
Code:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "c:\batch\test.cmd"

you then read the arguments from the batch file as %1 %2 etc up to nine.

Code:
@echo off
echo hello %1

save that as hello.cmd and run with the argument root.

c:\>hello.bat root

and it'll say "hello root"

you can pass any argument you like.
 
Well, I learned somthing new today. Thank you Root. :)
I will say that it defeats the reason though. The user wants to pass commands. Your method (which works) seems more complicated then it needs to.

You can send any "argument" to the command prompt, but that does not help with an already executed batch file. If I am wrong, please correct me but I think that is what they where asking about.
 
Last edited:
Quite right,

I should have read the question properly.

The code I wrote expects you to get all your variables up front, either entered as arguments when launching the batch file, or by a series of prompts by a vbs that are then used to launch the batch file with arguments...

This code will wait for you to enter a variable and store it as such.
Code:
Set /p name="What is your name? "
Echo %name

What you should notice about this code is:
There is no error checking. No type checking, no provision for spaces or lack of them, etc...

Batch files can be useful, but generally only in the confines of getting something done that you are needing to do again and again (eg a batch process)...

It's not a good language to write things that you want to use long term or release or use to support something long term..,
 
Back
Top Bottom