Computer Forums

Computer Forums (https://www.computerforums.org/forums/)
-   Programming (https://www.computerforums.org/forums/programming/)
-   -   Make .bat and .vbs work together! (https://www.computerforums.org/forums/programming/make-bat-vbs-work-together-227556.html)

scgryan@gmail.com 12-27-2015 11:03 AM

Make .bat and .vbs work together!
 
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

Draygoes 12-27-2015 11:07 AM

Re: Make .bat and .vbs work together!
 
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.

scgryan@gmail.com 12-27-2015 11:07 AM

Re: Make .bat and .vbs work together!
 
Wow fast reply


Sent from my iPhone using Computer Forums

Draygoes 12-27-2015 11:13 AM

Re: Make .bat and .vbs work together!
 
Did that help?

root 12-27-2015 12:38 PM

Re: Make .bat and .vbs work together!
 
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.

Draygoes 12-27-2015 12:52 PM

Re: Make .bat and .vbs work together!
 
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.

root 12-28-2015 06:33 PM

Re: Make .bat and .vbs work together!
 
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..,


All times are GMT -5. The time now is 02:55 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0