How do you pass a vb script variable to a batch file?

  • Thread starter Thread starter Guest
  • Start date Start date
Mike said:
Does anyone know how to do this?

Thanks,

Write them to standard output, then get the batch file to pick them up like
so:

@echo off
for /F %%* in ('your script command goes here') do set vars=%%*
echo Variables=%vars%

Don't forget the single quotes inside the brackets!
 
I don't understand. This is what I came up with:

for /F %%* in ('cscript.exe "C:\Documents and Settings\mroush\Desktop\New
Folder\GetName.vbs"') do set vars=%%*
echo Variables=%vars%
pause
"C:\Program Files\Network Associates\PGPNT\PGP.exe" -o "C:\Documents and
Settings\mroush\Desktop\New Folder\toefl.txt" "C:\Documents and
Settings\mroush\Desktop\New Folder\%vars%"
 
That's about it. What is the question?


Mike said:
I don't understand. This is what I came up with:

for /F %%* in ('cscript.exe "C:\Documents and Settings\mroush\Desktop\New
Folder\GetName.vbs"') do set vars=%%*
echo Variables=%vars%
pause
"C:\Program Files\Network Associates\PGPNT\PGP.exe" -o "C:\Documents and
Settings\mroush\Desktop\New Folder\toefl.txt" "C:\Documents and
Settings\mroush\Desktop\New Folder\%vars%"
 
I keep getting the following output when I run this.

variables=Input

but what I need it to be is the filename stored in a variable in the vbs
file that I am executing?
 
"Input" must be the last string written to standard output.
Try this for testing purposes:

cscript.exe "C:\Documents and Settings\mroush\Desktop\New
Folder\GetName.vbs" > c:\test.txt

Now examine c:\test.txt. What does it contain? Where
is the variable you wish to pass back to the batch file?
 
I get the filename in the test.txt file which is what I want to pass back to
the batch file. The variable I want to pass back is located in the
CheckNames.vbs file.
 
I got it stupid me, I left the double quotes out around the path to the vbs
file. I really appreciate your help on this Pegasus!
 
Hi there,

I would like to ask how will I pass a parameter in vbscript using that for loop?

for /F %%* in ('cscript.exe "C:\dir_list.vbs"') do set vars=%%*
echo variables=%vars%

this works, but I have to pass some argument in the dir_list.vbs..

When I try to do something like this:
(I based on this example: [cscript test.vbs /a:"a value" "another value"])

for /F %%* in ('cscript.exe "C:\dir_list.vbs /a:"value1""') do set vars=%%*
echo variables=%vars%

it didn't work. Even tried to remove the double quotes in the value1.
It only output/echo "variables=Input" instead of "variables=value1"
Any idea how will I do it?
 
Last edited:
Back
Top