我刚刚从-->https://stackoverflow.com/a/5901991/4251338
@echo off
set ip_address_string="IPv4 Address"
rem Uncomment the following line when using older versions of Windows without IPv6 support (by removing "rem")
rem set ip_address_string="IP Address"
echo Network Connection Test
for /f "usebackq tokens=2 delims=:" %%f in (`ipconfig ^| findstr /c:%ip_address_string%`) do echo Your IP Address is: %%f
它打印了我机器上的几个IP地址:
Your IP Address is: xxx.xxx.xxx.100
Your IP Address is: xxx.xxx.xxx.174
但实际上我想连接/安装以下IP地址以及
net use P: /del /yes
net use P: \xxx.xxx.xxx.xxxd$testing
\xxx.xxx.xxx.xxxd$testing (Which is available network IP)
现在网络应该是这样的:P:Testing
。
你能帮我做这个吗。提前谢谢。
我真的很难弄清楚到底需要什么,以及为什么使用本地地址无法工作:
net use P: \127.0.0.1d$testing
或通过本地地址名称,该名称始终为localhost
net use P: \localhostd$testing
但是如果你真的需要IPv4地址活跃在互联网上:
@echo off
net use P: /del /yes
for /f "tokens=2 delims=:" %%f in ('ipconfig ^| findstr /c:"IPv4 Address"') do (
(ping -S %%f 8.8.8.8 -n 2 | findstr /i "TTL")>nul 2>&1 && net use P: "\%%fd$testing"
)