Solved

How Do You Pass a Filename as a Variable from a Batch File to a VBScript?

Posted on 2008-06-25
2
581 Views
Last Modified: 2012-08-14
I am trying to script out a process where a ZIP file gets renamed and then FTP'd.  I wrote a batch file that renames a ZIP file to include the current date and time.  I have another VBScript file to upload a specified file.  The filename is passed along fine as I tested it by running an echo and it showed the right name.  I'm stuck in the VBScript file where I'm trying to use the value of the variable with the filename as part of the file path.  The path tells the FTP application what file to upload.

The batch file has the following code to call the VBScript file:
WScript upload.vbs %name%

The VBScript has the following code to pick that up and display it to make sure it's correct:
Dim file_name
file_name = WScript.Arguments(0)
WScript.Echo file_name

I have a problem later in the script because it looks for a file named "&file_name", not the value of the variable "file_name".  My syntax is probably incorrect.:
MySite.Upload "C:\FILES\&file_name", "/WEBSITE/&file_name"

0
Comment
Question by:doser
2 Comments
 
LVL 21

Accepted Solution

by:
JesterToo earned 250 total points
Comment Utility
Change that line to this...

   MySite.Upload "C:\FILES\" & file_name, "/WEBSITE/" & file_name

Also, be aware that if your code ever needs to handle a "file_name" with an embedded space that more changes would be necessary.
0
 
LVL 1

Author Closing Comment

by:doser
Comment Utility
I knew it was something with my syntax, but I just couldn't figure it out.  I spent a whole day at the job working on just that part.  Thanks so much.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now