Solved

Pass DOS/Batch Variables to VBScript

Posted on 2008-06-25
3
4,389 Views
Last Modified: 2008-07-03
I am trying to pass a variable that I created in a batch file over to a VBScript.  In the batch file, I have a filename that the VBScript will use to call an FTP program to upload.  I have the following in the batch file:
Wscript upload.vbs SOMEFILE.zip

In my VBScript, I have this so I can at least see that the value is passed along:
Dim file_name
Set file_name = WScript.Arguments("0")
WScript.Echo "file_name"

I want the VBScript to take the value in "file_name" and use that to upload the specified file.  I'm really looking to get this part fixed so I can get it out of my head.  Any help is appreciated.  Thanks.
0
Comment
Question by:doser
  • 2
3 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 21868995
my first thought is that this should be:
Set file_name = WScript.Arguments(0)
(without quotes)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 21869010
Second thought is - specify the full path...probably not the problem, but can't hurt.

cscript c:\pathtofile\upload.vbs c:\pathtootherfile\SomeFile.zip
0
 
LVL 1

Accepted Solution

by:
doser earned 0 total points
ID: 21869652
I talked with a former boss and he helped me clear up some of my coding in my VBScript.  It should be as follows:
Dim file_name
file_name = WScript.Arguments(0)
WScript.Echo file_name
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

786 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