Set oArgs = WScript.Arguments For i = 0 to oArgs.Count - 1 WScript.Echo oArgs(i) Next
關(guān)于參數(shù)解析,這里給出一個Windows 2000 support tools中的一個腳本的例子。你可以復(fù)用這個函數(shù),以解析任何以/ArgName:Value形式指定的參數(shù)。
' searches for and returns the value of a command line argument of the form ' /argName:value from the supplied array. erases the entry in the array so ' that only untouched entries remain.
function GetArgValue(argName, args()) dim a dim v dim argNameLength dim x dim argCount dim fullArgName
' Get the length of the argname we are looking for argNameLength = Len(fullArgName) GetArgValue = "" ' default to nothing
for x = 0 To argCount if Len(args(x)) >= argNameLength then
a = Mid(args(x), 1, argNameLength) if UCase(a) = UCase(fullArgName) then
' erase it so we can look for unknown args later v = args(x) args(x) = ""
if Len(v) > argNameLength then GetArgValue = Mid(v, argNameLength + 1) exit function else GetArgValue = "" exit function end if end if end if next end function
Sub Include(sInstFile) Dim oFSO, f, s Set oFSO = CreateObject("Scripting.FileSystemObject") Set f = oFSO.OpenTextFile(sInstFile) s = f.ReadAll f.Close ExecuteGlobal s End Sub
Sub Include(sInstFile) Dim oFSO, f, s Set oFSO = CreateObject("Scripting.FileSystemObject") Set f = oFSO.OpenTextFile(sInstFile) s = f.ReadAll f.Close ExecuteGlobal s End Sub
使用的時候,這個把這個sub放在代碼里,然后用 Include "comm.vbs" 這樣來包含以下就可以了