cscript.exe调用vbs示例

test.vbs:
Dim ArgObj
Set ArgObj = WScript.Arguments
If ArgObj.Count < 1 Then
    msgbox "miss arguments!"
    WScript.Quit()
Else
    Select Case UCase(ArgObj(0))
        Case "ALERT"
             Alert ArgObj(1)
        Case "ADD"
            Add ArgObj(1), ArgObj(2)
        Case Else
            msgbox "arguments error!"
    End Select
             
End If

Sub Alert(username)
    msgbox "hello," & username
End Sub

Sub Add(a, b)
    msgbox CInt(a) + CInt(b)
End Sub

调用示例:
引用内容 引用内容
cscript.exe test.vbs
cscript.exe test.vbs alert mzwu
cscript.exe test.vbs add 5 6

cscript.exe可省略,一样能正常执行!

评论: 0 | 引用: 0 | 查看次数: 6191
发表评论
登录后再发表评论!