Solved

Getting command line arguments in VBScript running as a VBS file

Posted on 2001-07-14
2
1,562 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 30 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 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