Working with Command-Line Arguments
Microsoft® Windows® 2000 Scripting Guide
http://technet.microsoft.com/en-us/library/ee156618.aspx
How to pass arguments with VBScript
This sample script shows how to process command line arguments using Windows Scripting Host. The example below would be used such that you would save this code off into args.vbs file. Open a command line .
Type in args.vbs argument1 argument2 etc... just put spaces between your arguments.
Set ArgObj = WScript.Arguments
sArgCount = ArgObj.Count
For x = 0 to sArgCount - 1
msgbox ArgObj(x)
Next
set ArgObj = Nothing
Test script that shows how many arguments you've typed
Option Explicit
Dim vArg, aArgs(), iCount, args
If WScript.Arguments.Count = 0 Then
WScript.Echo "No Arguments Supplied"
WScript.Quit
Else
args = WScript.Arguments.Count
WScript.Echo "You entered " & args & " Arguments:"
ReDim aArgs(wscript.Arguments.Count - 1)
For iCount = 0 To WScript.Arguments.Count - 1
aArgs(iCount) = WScript.Arguments(iCount)
WScript.Echo aArgs(iCount)
Next
End If
Save above codes to args.vbs and run it like below:
csript args.vbs arg1 agr2 agr3
Advance arguments passing skills
http://ezinearticles.com/?VBScript---Pass-DOS-Like-Arguments-to-Your-Script-for-Flexibility-and-Control&id=542008
This article shows you how to make DOS like switches with your VBScript
dir /ad /b
doublespace /mount c:
Further reading:
http://ist.marshall.edu/ist334/wsh_arguments.html
http://www.keyongtech.com/5463227-regular-expression-to-detect-repeating
2010-02-24
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment