Solved

Pass DOS Variables to vbscript

Posted on 2003-12-05
3
2,465 Views
Last Modified: 2009-12-16
Is there a way to pass a variable through a command line to a vbscript file.

I have a script that counts how many records are in a file.  I want to pass a count to the vbscript to compare these two.

Something Like:

download.bat executes count.vbs 225

count.vbs the reads 225.

Is this possible or am I going to have to have the batch file write a file and then have the vbscript read the file.
0
Comment
Question by:1Adam12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
pbarrette earned 25 total points
ID: 9883461
Hi 1Adam12,

This really isn't a DOS variable issue. It's actually a vbscript issue.

You need to use something like this in your vbscript:
WScript.Arguments(0)

This should read in the first passed argument. In your example above, "WScript.Arguments(0)" would return "225".

Hope this helps,
pb
0
 

Author Comment

by:1Adam12
ID: 9883722
WScript.Arguments("0") worked.

Thanks!
0
 
LVL 10

Expert Comment

by:pbarrette
ID: 9884642
Hi 1Adam12,

Glad to help.

pb
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question