Q: Pass arguments to .vbs file thru .wsh file? 
Author Message
 Q: Pass arguments to .vbs file thru .wsh file?

Is it possible to pass arguments to the script in a .vbs file thru a .wsh
file created for the script file? I'd like to create several .wsh files
invoking the same .vbs file using different command line arguments. Anyone
know a solution?


Sat, 10 Feb 2001 03:00:00 GMT  
 Q: Pass arguments to .vbs file thru .wsh file?


Fri, 19 Jun 1992 00:00:00 GMT  
 Q: Pass arguments to .vbs file thru .wsh file?
Sure, try using something like this:

Dim oArgs
Dim nArguments

Set oArgs = WScript.Arguments

For nArguments = 0 to oArgs.Count - 1
       WScript.Echo "Argument #" & nArguments + 1 & " = " &
oArgs.Item(nArguments)
Next

You can then run the script like this:

  CSCRIPT MYSCRIPT.VBS arg1 arg2 name1 name2 test1 test2 lastarg
or
  WSCRIPT MYSCRIPT.VBS arg1 arg2 name1 name2 test1 test2 lastarg

See Ya!

Quote:

>Is it possible to pass arguments to the script in a .vbs file thru a .wsh
>file created for the script file? I'd like to create several .wsh files
>invoking the same .vbs file using different command line arguments. Anyone
>know a solution?



Sat, 10 Feb 2001 03:00:00 GMT  
 Q: Pass arguments to .vbs file thru .wsh file?

Quote:

> Sure, try using something like this:

> Dim oArgs
> Dim nArguments

> Set oArgs = WScript.Arguments

> For nArguments = 0 to oArgs.Count - 1
>        WScript.Echo "Argument #" & nArguments + 1 & " = " &
> oArgs.Item(nArguments)
> Next

> You can then run the script like this:

>   CSCRIPT MYSCRIPT.VBS arg1 arg2 name1 name2 test1 test2 lastarg
> or
>   WSCRIPT MYSCRIPT.VBS arg1 arg2 name1 name2 test1 test2 lastarg

> See Ya!


> >Is it possible to pass arguments to the script in a .vbs file thru a
> >.wsh file created for the script file? I'd like to create several .wsh
> >files invoking the same .vbs file using different command line
> >arguments. Anyone know a solution?

Okay, I had figured that part out.  The part I haven't got figured out
to my satisfaction is how to pass a RUNTIME argument - Say a file name
dropped onto a shortcut that invokes the script/wsh file.  My brief
forray into scripting has led me to conclude that this can only be done
through a BATCH FILE, as in ....


   wscript d:\wherever\myscript.vbs %1 %2 etc

First, scripts don't accept drag-and-drop and second when an item is
dropped on a shortcut it ends up as the first argument on the line after
the WScript string - before the name of the script.  This of course
results in a 'this is not a script' kind of an error message.

This just seems so much like a kludge.  After all, I kind of thought the
object was to provide a wholely GUI environment for scripting.

Am I right, or have I missed something?

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Mon, 12 Feb 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. passing values from .vbs file to command line under WSH

2. Registering file type thru vbs

3. Access vbs file thru ASP

4. How do you pass parameters from a batch file to a VBS file

5. Passing arguments to a batch file launched from a VBscript

6. Passing Arguments to HTA file

7. Convert a WSH-file to a VBS-file

8. Argument to a VBS file

9. Do vbs files accept arguments in entry ??

10. Passing argument to .VBS script from HTML page

11. How to pass back variables from called vbs from vbs using wsh

12. wsf - passing arguments between vbs-part and js-part

 

 
Powered by phpBB® Forum Software