![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | vbscript arguments Wrote a program to take arguments but really all I did was write a wrapper around the program that I am passing aruguments to. So it can be 1 to 6 arguments and I just pass whats typed at command line. I can not assign each argument. I know with the script code below I can get count and print each argument to console. What I need to be able to do is capture each argument and adding a space between each one and store into varible. For example, MyVbscript.vbs c:\tmp 4 test.log 'In this scenerio three parameters are passed which I will just pass to the program I am executing inside vbscript. The code below would print out c:\temp 4 test.log I need the following c:\temp 4 test.log ' need this string stored in a varibale. Set objArgs = WScript.Arguments WScript.Echo "Total number of arguments: " & WScript.Arguments.Count for each sArgs in objArgs sArgs = sArgs WScript.Echo sArgs Next |
My System Specs![]() |
| | #2 (permalink) |
| | Re: vbscript arguments "Big D" <BigDaddy@xxxxxx> wrote in message news:OCiJ1J92IHA.5112@xxxxxx Quote: > Wrote a program to take arguments but really all I did was write a wrapper > around the program that I am passing aruguments to. So it can be 1 to 6 > arguments and I just pass whats typed at command line. I can not assign > each argument. > > I know with the script code below I can get count and print each argument > to console. What I need to be able to do is capture each argument and > adding a space between each one and store into varible. > > > For example, > > MyVbscript.vbs c:\tmp 4 test.log 'In this scenerio three parameters are > passed which I will just pass to the program I am executing inside > vbscript. > > The code below would print out > c:\temp > 4 > test.log > > I need the following > > c:\temp 4 test.log ' need this string stored in a varibale. > > > Set objArgs = WScript.Arguments > > WScript.Echo "Total number of arguments: " & WScript.Arguments.Count > > for each sArgs in objArgs > sArgs = sArgs > WScript.Echo sArgs > Next example ======== strLine = "" Set objArgs = Wscript.Arguments For Each strArg in objArgs If (strLine = "") Then strLine = strArg Else strLine = strLine & " " & strArg End If Next Wscript.Echo strLine ======= Also, you may want to enclose the arguments in quotes, in case the might be spaces. Then: ======== strLine = "" Set objArgs = Wscript.Arguments For Each strArg in objArgs If (strLine = "") Then strLine = """" & strArg & """" Else strLine = strLine & " """ & strArg & """" End If Next Wscript.Echo strLine -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to do No hang up VBScript (nohup for VBScript) | VB Script | |||
| getting arguments from pipe | PowerShell | |||
| arguments count | PowerShell | |||
| Getting arguments from STDIN when command line arguments are missing | PowerShell | |||
| Arguments parsing | PowerShell | |||