Solved

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

Posted on 2008-06-25
2
585 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
ID: 21871234
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
ID: 31470828
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

856 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