Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

passing variables to batch file

6 views
Skip to first unread message

Lynn

unread,
Jul 31, 2005, 7:05:45 AM7/31/05
to
hi,
i need to run a batch file using vbscript.
the contents of the batch file is echo %1 %2

in vbscript i have WshShell.Run "cmd.exe /c c:\run.bat"
how can i pass %1 and %2 from vbscript to run.bat?

thanks


Jerold Schulman

unread,
Jul 31, 2005, 7:40:22 AM7/31/05
to

WshShell.Run "cmd.exe /c c:\run.bat Param1 Param2"


WshShell.Run "cmd.exe /c c:\run.bat AAA BBB"

or

p0="cmd.exe /c c:\util\test8.bat"
p1="XYZ"
p2="ABC"
runit=p0 & " " & p1 & " " & p2
WshShell.Run runit

Lynn

unread,
Jul 31, 2005, 12:21:11 PM7/31/05
to
any idea why the output is

C:\>echo [object] [object]
[object] [object]

"Jerold Schulman" <Je...@jsiinc.com> wrote in message
news:cgdpe152fh5pgt13q...@4ax.com...

Jerold Schulman

unread,
Aug 1, 2005, 7:39:12 AM8/1/05
to

Make sure the batch starts with
@echo off

Sean M. Loftus

unread,
Aug 1, 2005, 11:29:21 AM8/1/05
to
I had a similar problem not too long ago and found this switch that is
available to hold variables for your batch files. I needed it to hold a file
name typed in at the CMD line and run different VB scripts against it in
succession so I didn't have to do them one at a time. You can probably
modify it to your own use.

Search.bat
-------------------------------------------------------------
@color 0B

@set /p userin=Please enter the INPUT file name and path:

cscript UML_SearchScript_EID_DoesExist.VBS %userin%
cscript UML_SearchScript_SAM_DoesExist.VBS %userin%
cscript UML_SearchScript_SID_DoesExist.VBS %userin%
cscript UML_SearchScript_UPN_DoesExist.VBS %userin%

Exit
--------------------------------------------------------------


--
Sean M. Loftus
Enterprise Architect
Loftus Consulting, Inc.
www.LoftusConsulting.com

sean(removeme)@loftus.org

"Lynn" <Marr...@yah00.c0m> wrote in message
news:u74lS$blFH...@TK2MSFTNGP15.phx.gbl...

0 new messages