[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Getting command line arguments in VBScript running as a VBS file

Posted on 2001-07-14
2
Medium Priority
?
1,566 Views
Last Modified: 2007-11-27
Hello All,
 I would like to write a VBS file, which takes some arguments on the command line

cscript myvvbsfile.vbs arg1 arg2 arg3

How do I retrieve this arguments in VBS?

Thanks in advance,
Nicholas Waltham
0
Comment
Question by:nwaltham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
robbert earned 120 total points
ID: 6281870
There is the (zero-based) Arguments collection:

For i = 0 To cscript.arguments.count - 1
    x = cscript.arguments(i)
Next

For Each arg In cscript.arguments
    x = arg
Next

WSH reference
http://msdn.microsoft.com/scripting/windowshost/doc/wshtoc.htm
WSH arguments
http://msdn.microsoft.com/scripting/windowshost/doc/wsObjWshArguments.htm
0
 

Expert Comment

by:caller9
ID: 7909202
This is a great answer but didn't work for me. Replace the cscript with wscript like so:

For Each arg In wscript.arguments
   x = arg
Next

This worked like a charm for me.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 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