不知何故,我需要验证用户输入,以防错误用户返回inpu 2次正确值。
Enter
也可以很好地防止空输入。
是否可以在MS Windows中的批处理文件中执行此操作?
@ECHO OFF
set /p ip=IP Address:
set /p mask=Network Mask:
set /p gate=Port:
timeout /t 3
netsh interface ip set address "Local Area Connection" static %ip% %mask% %gate% 1
ECHO Done
timeout /t 3
ipconfig
timeout /t 3
EXIT
答案 0 :(得分:1)
我确实喜欢这个......
@ECHO OFF
color 17
ECHO ----------------------------
ECHO Configuracion de IPs
ECHO ----------------------------
:STARTINPUT
set ip=NOTOK
set mask=NOTOK
set gate=NOTOK
rem --------------------------------------------------------------------
set /p ip1=Direccion IP :
set /p ip2=Verificar el Direccion IP :
If %ip1%==%ip2% (
ECHO Verificado: %ip1%
set ip=OK
GOTO MASKINPUT
) else (
ECHO Direccion IP "%ip1%" no ha sido verificado!!!
GOTO STARTINPUT
)
rem --------------------------------------------------------------------
:MASKINPUT
set /p mask1=Mascara de red :
set /p mask2=Verificar el mascara de red :
If %mask1%==%mask2% (
ECHO Verificado: %mask1%
set mask=OK
GOTO GATEINPUT
) else (
ECHO Mascara de red "%mask1%" no ha sido verificado!!!
GOTO MASKINPUT
)
rem --------------------------------------------------------------------
:GATEINPUT
set /p gate1=Puerta de enlace:
set /p gate2=Verificar el puerta de enlace:
If %gate1%==%gate2% (
ECHO Verificado: %gate1%
set gate=OK
rem timeout /t 3
ECHO Cambiando direcciones...
netsh interface ip set address "Local Area Connection" static %ip% %mask% %gate% 1
ECHO Completado
timeout /t 3
ipconfig
timeout /t 3
rem EXIT
) else (
ECHO Puerta "%gate1%" no ha sido verificado!!!
GOTO GATEINPUT
)