有人可以帮我解决这个问题吗?我有一个批处理文件,我试图根据我当前的内部 IP 地址连接几个网络驱动器。问题是,它输出以下内容:
家 192.168.2.99 地下室
它应该在哪里输出:Home 192.168.2.99
这是代码:
@echo off
@for /F "tokens=2 delims=:" %%i in ('"ipconfig | findstr IP | findstr 192."') do SET LOCAL_IP=%%i
@if ("%LOCAL_IP%" == "192.168.2.99") Call ConnectHome else (Call ConnectBasement)
:ConnectHome
@echo Home %LOCAL_IP%
:ConnectBasement
@echo Basement
@REM net use R: \\192.168.2.98\Storage
@REM net use S: \\192.168.2.98\MyStuff
@REM net use T: \\192.168.2.98\Server
我还尝试将 IF 语句替换为:
@if ("%LOCAL_IP%" == "192.168.2.99") goto ConnectHome else (goto ConnectBasement)
和:
@if ("%LOCAL_IP%" == "192.168.2.99") goto :ConnectHome else (goto :ConnectBasement)
结果总是一样的......操作系统是Windows 7 Pro