关于在批处理文件的 ROUTE ADD 语法上使用变量,我有一个非常菜鸟的问题。简而言之,我要求输入 2 个值,然后我使用它们创建 2 个特定的 IP 地址,然后我想将它们传递给 ROUTE ADD 语法,但是在我的操作系统(Windows7 x64)上,当我运行脚本时,我可以看到正确的 IP01 和 IP02 变量,但我不能有 ROUTE ADD 命令来识别 IP01 和 IP02...即使我把 %IP01% 和 %IP02% 显示的命令在屏幕上什么也没写,所以我不能继续处理批处理文件. PING 命令也有同样的问题。
这是我编写的原始代码:
@ECHO OFF
REM ******************************
REM ROUTE MAP for ENDIA-eWON
REM ******************************
CLS
ECHO.
COLOR 0A
ECHO.+ROUTE MAP 10.128.X.0 with eWON-sn + IP 172.31.1.X
ECHO.+PING ROUTE JUST DEFINED, TO CHECK IT
ECHO.----------------------------
ECHO.Author: aColussi@atomat.com
ECHO.v1.00
ECHO.
ECHO.
ECHO.
SET /P RGWsn=Insert eWON sn (RGWsn):
SET /P EndianIP=Insert last value X for the Endian network (172.30.1.X):
REM ******************************
REM DEFINE IP01 (eWON network) and IP02 (ENDIAN network)
REM ******************************
SET IP01 = 10.128.%RGWsn%.0
SET IP02 = 172.30.1.%EndianIP%
REM TEST THE 2 VALUES JUST DEFINED
SET IP01
SET IP02
PAUSE
@ECHO ON
REM ADD THE ROUTE
ROUTE ADD %IP01% MASK 255.255.255.0 %IP02% METRIC 1
PAUSE
@ECHO OFF
REM TEST THE ROUTE AND THE PING OF THE eWON ASSOCIATED DEVICE (.254)
ECHO.
ECHO.VIEW THE ROUTES ON OUR WORKSTATION
ROUTE PRINT |MORE
PAUSE
ECHO.
ECHO.PING-TEST FOR THE JUST-ADDED ROUTE/IP (USING eWON .254)
SET IP03 = 10.128.%RGWsn%.254
PING %IP03%
PAUSE