Solved

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

Posted on 2008-06-25
2
582 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

910 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

16 Experts available now in Live!

Get 1:1 Help Now