如何将VBScript生成的参数传递给已打开的批处理文件?

时间:2014-05-08 20:03:16

标签: windows batch-file file-io vbscript

我编写了一个批处理文件,它将两个参数传递给VBScript文件,如下所示:

call "Command_case.vbs" "%COMMAND%" "%PARAM%"

现在,在我的VBScript中,我有一个switch(well,select case)语句来检查%COMMAND%是什么,我想将参数返回到(仍然打开的)批处理文件,这是我的VBScript:

Select Case WScript.Arguments(0)
Case "decrypt"

Case "encrypt"

Case "open"

Case "archive"

Case "expand"

Case else
    'in here I would like to return an argument to the batch of "null", or something along those lines.
End Select

1 个答案:

答案 0 :(得分:0)

您可以使用wscript.Quit(Numeric_Value)设置错误级别 其中Numeric_Value是介于-999999999和999999999之间的值

Select Case WScript.Arguments(0)
Case "decrypt"

Case "encrypt"

Case "open"

Case "archive"

Case "expand"

Case else
    wscript.Quit(2)
End Select

在您的批次中:

call "Command_case.vbs" "%COMMAND%" "%PARAM%"
if %errorlevle% equ 2 echo ELSE