如何转移参数在批处理文件时,有超过10个参数 [英] How to shift arguments in batch files when there are more than 10 arguments

查看:269
本文介绍了如何转移参数在批处理文件时,有超过10个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何使用VBScript的像本地脚本语言编写批处理文件为Windows 7。

I am learning how to write batch files for Windows 7 using the VBScript like native scripting language.

我想我没有使用Windows脚本主机或电源外壳。我使用简单的旧式的VBScript的语法。

I suppose I am not using the Windows Scripting Host or the Power Shell. I am using the simple old style VBScript like syntax.

我不明白如何转移的参数时,有超过9参数(或10包括批处理文件的名称)传递给该批处理文件。

I don't understand how to shift arguments when there are more than 9 arguments (or 10 including the name of the batch file) passed to the batch file.

你能教教我吗?

让我们假设你调用下面的参数我的批处理文件:

Let us assume that you called my batch file with the following arguments:

C:\>call my.bat "one" "two" "three" "four" 
    "five" "six" "seven" "eight" "nine" "ten" "eleven"

您将如何访问这些参数 10 十一从内部 my.bat

How would you access the arguments ten and eleven from within my.bat?

推荐答案

这是从ss64.com

this is the batch taken from ss64.com

@echo off
:start
if "%1"=="" (goto :exit)
:: Do whatever with token %1
Echo [%1] 
:: Shift %2 into %1 
SHIFT
goto :start

:exit
::pause

调用批处理有超过10个参数,它会显示所有的

call that batch with more than 10 arguments, it will display all

    shift.bat 1 2 3 4 5 6 7 8 9 10 11
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]

这篇关于如何转移参数在批处理文件时,有超过10个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆