• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2476
  • Last Modified:

Pass DOS Variables to vbscript

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
1Adam12
Asked:
1Adam12
  • 2
1 Solution
 
pbarretteCommented:
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
 
1Adam12Author Commented:
WScript.Arguments("0") worked.

Thanks!
0
 
pbarretteCommented:
Hi 1Adam12,

Glad to help.

pb
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now