Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6540024
  • 博文数量: 915
  • 博客积分: 17977
  • 博客等级: 上将
  • 技术积分: 8846
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-26 09:59
个人简介

一个好老好老的老程序员了。

文章分类

全部博文(915)

文章存档

2022年(9)

2021年(13)

2020年(10)

2019年(40)

2018年(88)

2017年(130)

2015年(5)

2014年(12)

2013年(41)

2012年(36)

2011年(272)

2010年(1)

2009年(53)

2008年(65)

2007年(47)

2006年(81)

2005年(12)

分类: WINDOWS

2007-08-14 11:13:54

DOS、批处理修改IP

Dos控制台设置IP的方法

c:\>netsh (然后执行netsh这个命令) 
  netsh>interface (netsh命令的子命令) 
  interface>ip (interface命令的子命令) 
  interface ip>set (interface ip命令的子命令) 
  下列指令有效: 
  
  set address - 设置指定的接口的 ip 地址或默认网关。 
  set dns - 设置 dns 服务器模式和地址。 
  set wins - 设置 wins 服务器模式和地址。 
  interface ip>set address "本地连接" static
  192.168.0.2 255.255.255.0 192.168.0.1 
  1 (设置ip地址) 
  确定。 
  interface ip>exit


       最近发现一些电脑应用了策略,使得超级用户耶不能够修改电脑IP。于是就想能不能通过DOS控制台来修改电脑的IP。于是乎我发现了这个DOS命令行。

C:>_
netsh -c interface ip dump > d:\config.txt

         上面的命令将这台电脑上的启用的连接地址列出来了。也就是IP SCRIPT.
那么如何修改IP地址呢。
        上面的命令将IP地址保存为一个TEXT文件。在这个TEXT文件中修改相应的数据,然后将其导入。就完成了修改IP地址的行为。


config.txt content


# ----------------------------------
# 接口 IP 配置
# ----------------------------------
pushd interface ip


# "本地连接 6" 的接口 IP  配置

set address name="本地连接 6" source=static addr=192.168.1.11 mask=255.255.255.0
set address name="本地连接 6" gateway=192.168.1.1 gwmetric=0
set dns name="本地连接 6" source=static addr=none register=PRIMARY
set wins name="本地连接 6" source=static addr=none


popd
# 接口 IP 配置结束

       导入IP地址的DOS 命令如下:
C:>_
netsh -f d:\config.txt config.txt

_______________________________________________________________________________________________________

批处理设置IP

把下面内容保存为.bat批处理文件格式,修改相应的IP地址,执行便可修改IP

下面是自定义的

@echo off


echo This is the begin..


netsh interface ip set address name="本地连接" source=static addr=192.168.1.188 mask=255.255.255.0

rem 设置本地连接的ip地址为:192.168.1.188,子网掩码为:255.255.255.0


netsh interface ip set address name="本地连接" gateway=192.168.1.8 gwmetric=0


rem 设置网关


netsh interface ip set dns name="本地连接" source=static addr=192.168.1.8 register=PRIMARY


rem 设置主dns


netsh interface ip add dns name="本地连接" addr=192.168.1.1


rem 设置备份dns


netsh interface ip set wins name="本地连接" source=static addr=none


rem 设置wins


echo This is the ending..


下面是自动获取的批处理文件内容

@echo off


echo This is the begin..


netsh interface ip set address name="本地连接" source=dhcp


netsh interface ip set dns name="本地连接" source=dhcp register=PRIMARY


netsh interface ip set wins name="本地连接" source=dhcp


echo This is the ending..

 

其它

cmd /c netsh interface ip set address name="本地连接" source=static addr=192.168.0.2 mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1

cmd /c netsh interface ip set dns name="本地连接" source=static addr=202.101.98.55


导出的命令:netsh interface ip dump >c:\ip.txt

导入的命令:netsh exec c:\ip.txt
_________________________________________________________________________________________________________

执行程序同时导入注册表的批处理


我需要导入的注册表程序是E盘的1.reg文件,我需要后执行的程序是D盘TENCENT目录的qq.exe
下面是NT用的批处理文件内容:
 程序代码
@echo off
reg import e:\1.reg
start D:\Tencent\QQ.exe
exit

这样运行后的效果是别人看不见导入注册表的过程,只会直接看见QQ启动了,也没有一个难看的CMD窗口在后面,和直接运行QQ的情况一样。
由于注册表文件导入必须先于程序执行,所以你想运行XX程序,就得通过执行这个批处理程序来进行。明白吧~~
98应该是这个样子:
 程序代码
@echo off
regedit /s e:\1.reg
start.exe D:\Tencent\QQ.exe
exit

阅读(3868) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~