Passing values to variables in a .vbs file 
Author Message
 Passing values to variables in a .vbs file

I want to run a .vbs file from the command prompt. The
code in the .vbs file is as follows :
Dim o
Set o = CreateObject("myObject")
o.SourceFile =
o.OutputFile =
o.Run

While putting in the name of the.vbs file at command
prompt, I also want to specify names with paths of files
(as parameters), which should be passed onto the .vbs to
set values of the variables o.SourceFile & o.OutputFile.
What is the right syntax for achieving the above - both as
regards the command prompt and also what code do i need to
add in the .vbs file.



Mon, 28 Jun 2004 04:10:41 GMT  
 Passing values to variables in a .vbs file
The VBScript code could be (a file called myscript.vbs):

If Wscript.Arguments.Count < 2 Then
  Msgbox "Error"
  Wscript.Quit(1)
End If
SourceFile = Wscript.Arguments(0)
OutputFile = Wscript.Arguments(1)

At the command prompt, if you enter

cscript
myscript.vbs "c:\windows\myfile.txt" "c:\temp\output.txt"

then SourceFile will be "c:\windows\myfile.txt"
and OutputFile will be "c:\temp\output.txt"

Richard

Quote:
>-----Original Message-----
>I want to run a .vbs file from the command prompt. The
>code in the .vbs file is as follows :
>Dim o
>Set o = CreateObject("myObject")
>o.SourceFile =
>o.OutputFile =
>o.Run

>While putting in the name of the.vbs file at command
>prompt, I also want to specify names with paths of files
>(as parameters), which should be passed onto the .vbs to
>set values of the variables o.SourceFile & o.OutputFile.
>What is the right syntax for achieving the above - both
as
>regards the command prompt and also what code do i need
to
>add in the .vbs file.
>.



Mon, 28 Jun 2004 05:24:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing values to a .VBS file...

2. Pass a value to a vbs file

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

4. passing variables from .bat files to .vbs scripts

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

6. How to pass the value of a variable to Session object

7. Pass VBScript Variable to HTML Textbox via Value Property

8. Passing variable values...

9. Passing jscript value to vbscript variable

10. Passing variable value as parameter

11. Passing form values to other variables

12. Passing a ASP Session Variable Value into a JavaScript function

 

 
Powered by phpBB® Forum Software