吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4787|回复: 5
收起左侧

[分享] IP转本地批处理

[复制链接]
Rookietp 发表于 2013-2-18 11:13
@echo off
set 目标IP= ///这里设置IP
FOR /F "tokens=2*" %%i IN ('ipconfig/all^|find /i "Ethernet adapter "') DO set name=%%j
FOR /F "tokens=1* delims=:" %%i in ("%name%") do set 网卡名称=%%i
FOR /F "tokens=4*" %%i IN ('ipconfig/all^|find /i "DNS Servers"') DO set name=%%j
FOR /F "tokens=2* delims=:" %%i in ("%name%") do set DNS服务器=%%i
FOR /F "tokens=4*" %%i IN ('ipconfig/all^|find /i "IP Address"') DO set name=%%j
FOR /F "tokens=2* delims=:" %%i in ("%name%") do set IP地址=%%i

FOR /F "tokens=4*" %%i IN ('ipconfig/all^|find /i "Subnet Mask"') DO set name=%%j
FOR /F "tokens=2* delims=:" %%i in ("%name%") do set 子网掩码=%%i

FOR /F "tokens=4*" %%i IN ('ipconfig/all^|find /i "Default Gateway"') DO set name=%%j
FOR /F "tokens=2* delims=:" %%i in ("%name%") do set 默认网关=%%i

FOR /F "tokens=4*" %%i IN ('ipconfig/all^|find /i "Dhcp Enabled"') DO set name=%%j
FOR /F "tokens=2* delims=:" %%i in ("%name%") do set Dhcp=%%i

@echo on
echo "%Dhcp%"
rem goto exit
IF "%Dhcp%"==" No" goto staticip
echo "设置静态地址"
netsh interface ip set address "%网卡名称%" static %IP地址% %子网掩码%
netsh interface ip add address "%网卡名称%" %目标IP% %子网掩码%
netsh interface ip set address "%网卡名称%" gateway=%默认网关% gwmetric=1

netsh interface ip set dns "%网卡名称%" static %DNS服务器%
goto exit

:staticip
echo "只添加IP"
netsh interface ip add address "%网卡名称%" %目标IP% %子网掩码%

:exit
echo "处理完成"

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

xingfukaiera 发表于 2013-2-18 11:23
楼主,这个代码里能加上高级-添加个ip吗
1354669803 发表于 2013-2-18 12:26
xingfukaiera 发表于 2013-2-19 13:51
xiaofe11 发表于 2013-2-19 14:47
佩服 大牛   受教了
庚琰1001 发表于 2013-2-19 18:28
代码可以,为什么不弄个软件呢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-21 12:54

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表