分析命令行参数(VBScript)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分析命令行参数(VBScript)相关的知识,希望对你有一定的参考价值。
Function CmdLineParam(AStartAt, AsingleSwitch, AMatchCase, ALongSwitch, AAssigned, APosition, AFollowing) ' AStartAt Which argument position to start at (Zero based). ' ASingleSwitch single character param char. -a -A ' AMatchCase singleSwitch should be came case for a match ' ALongSwitch Long Switch value that is preceed by --. i.e. --test --file= ' AAssigned Everything following the single switch char, or everything after = in a LongSwitch ' APosition Which value on the command line this matched ' AFollowing Value of next parameter on the command line ' Returns true if the parameter was found Dim Found Dim c1 Dim count Dim args Dim ASign Set args = WScript.Arguments Found = False c1 = AStartAt count = args.count While Not found And c1 < count If (Left(args(c1),2)) = "--" Then If UCase(Mid(args(c1),3,Len(ALongSwitch))) = (UCase(ALongSwitch)) Then Found = True ASign = InStr(args(c1),"=") If ASign <> 0 Then AAssigned = Mid(args(c1),ASign+1,Len(args(c1))) Else AAssigned = "" End If End If ElseIf (Left(args(c1),1)) = "-" Then If AMatchCase = True Then ' make sure it matches If Mid(args(c1),2,1) = ASingleSwitch Then found = True APosition = c1 AAssigned = Mid(args(c1),3,Len(args(c1))) If (c1 < count+1) Then AFollowing = args(c1+1) End If Else ' we don't care about case If UCase(Mid(args(c1),2,1)) = UCase(ASingleSwitch) Then found = True APosition = c1 AAssigned = Mid(args(c1),3,Len(args(c1))) End If End If End If AFollowing = "" If Found And (c1 < count-1) Then AFollowing = args(c1+1) End If c1 = c1 + 1 Wend CmdLineParam = Found End Function
以上是关于分析命令行参数(VBScript)的主要内容,如果未能解决你的问题,请参考以下文章