batch delimiter命令不起作用

时间:2016-09-27 19:51:28

标签: batch-file

我是Windows批处理的新手,遇到了一个我无法弄清楚的问题。我编写一个批处理命令,用户将输入一个IP地址,例如11.152.43.78,我需要分隔IP地址,这样我就可以在最后一个字节中加或减数字。我的问题是,一旦输入IP地址,我的批处理命令就会关闭。我通过本网站上的示例将此命令放在一起。任何帮助将不胜感激。

echo. Enter IP address of the CSR on the site.
echo. Example: 11.152.34.82
set /p IP="IP Address: "
for /F tokens=1,2,3,4 delims=." %%a in ("%IP%") do echo %%a, %%b, %%c, %%d
pause
cls
echo. select the technology you are trying to restore
echo. 1: AWS
echo. 2: PCS
echo. 3: LTE 1
echo. 4: LTE 2
set /p w="Enter number: "

1 个答案:

答案 0 :(得分:0)

以下是您的想法:

@Echo Off
Echo= Enter IP address of the CSR on the site.
Echo= Example: 11.152.34.82
Set/P "IPA= "
Call :Sub %IPA:.= %

Rem Your commands using new %IPA% here:
Echo= Your new IP address is %IPA%

Timeout -1 >Nul
Exit/B

:Sub
    ClS
    Echo= Select the technology you are trying to restore.
    Echo= [1] AWS
    Echo= [2] PCS
    Echo= [3] LTE 1
    Echo= [4] LTE 2
    Choice /C 1234 /N
    If ErrorLevel 4 Set "LO=73"
    If ErrorLevel 3 Set "LO=61"
    If ErrorLevel 2 Set "LO=44"
    If ErrorLevel 1 Set "LO=27"
    Set "IPA=%1.%2.%3.%LO%"