本批处理可以在Windows系统下修改多块网卡的IP地址,掩码,网关和DNS信息。加入了删除默认路由,自动添加两块网卡路由信息。(请根据需要修改ip地址,网卡名称和路由信息)
@echo off
echo 正在修改第一块网卡配置
cmd /c netsh interface ip set address name="本地连接" source=static addr=172.16.45.111 mask=255.255.255.0 gateway=172.16.45.254 gwmetric=auto
cmd /c netsh interface ip set dns name="本地连接" source=static addr=8.8.8.8
cmd /c netsh interface ip add dns name="本地连接" addr=202.106.0.20
echo 正在修改第二块网卡配置
cmd /c netsh interface ip set address name="本地连接 1" source=static addr=172.16.45.112 mask=255.255.255.0 gateway=172.16.45.254 gwmetric=auto
cmd /c netsh interface ip set dns name="本地连接 1" source=static addr=8.8.8.8
cmd /c netsh interface ip add dns name="本地连接 1" addr=202.106.0.20
echo 网卡配置修改完毕
echo 正在删除默认路由
route delete 0.0.0.0
echo 正在添加第一条路由
route add -p 10.0.0.0 mask 255.0.0.0 10.28.127.254
echo 正在添加第二条路由
route add -p 0.0.0.0 mask 0.0.0.0 192.168.27.254
ipconfig /all
pause
标签归档:Windows
WordPress用404页面去掉链接index.php方法
Windows的主机都是用IIS做为网站服务的,但是在IIS的环境下安装Wordpress后,固定链接里的链接都会多一个index.php,这对搜索引擎来说并不利于收录的,Linux主机的apache是没有这个问题的。所以要去掉这个index.php可以采用404自定义错误页面的方法,在404错误页面添加如下内容即可。(注意去掉< ?php之间的空格)
< ?php
$ori_qs = $_SERVER['QUERY_STRING'];
$pattern = '/[^;]+;[^:]+://[^/]+(/[^?]*)(?:?(.*))?/i';
preg_match($pattern, $ori_qs, $matches);
$_SERVER['PATH_INFO'] = $matches[1] . '?' . $matches[2];
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
$query_args = explode(‘&’, $matches[2]);
unset($_GET);
foreach ($query_args as $arg)
{
$the_arg = explode('=', $arg);
$_GET[$the_arg[0]] = $the_arg[1];
}
include('index.php');
?>
Trustedinstaller.exe进程占用CPU资源解析
Trustedinstaller.exe这个进程在开机后,非常占用CPU资源。TrustedInstaller.exe是“Windows Modules Installer”这个服务的进程,路径 C:\Windows\servicing\TrustedInstaller.exe。当系统进行Windows Update,或者安装某些微软发布的安装包时,Windows Modules Installer服务会自动运行,以便可以修改或者替换系统文件。所以如果你开了系统自动更新,那么开机的时候这个进程就会自动运行去安装补丁。注:Trustedinstaller.exe存在于Windows Vista和Windows 7系统中,Windows XP是没有这个进程的。如果想禁止Trustedinstaller.exe这个进程自动运行,可以关闭系统自动更新。
Windows批处理ping一个网段IP
Linux系统可以用nmap批量ping,Windows当然也可以,Windows版本的nmap可以网上搜索下载。不过要装软件毕竟不太方便,最方便的还是利用系统自身环境,下面这个脚本可以轻松实现批量ping。
rem 1.bat
for /l %%p in (1,1,32) do @ping 10.28.126.%%p -n 1 |find “reply” /i >>c:\1.txt
将上面内容保存为1.bat,双击即可执行,结果信息自动保存到C盘1.txt文本中。
Windows批处理添加DNS和多网卡路由
通过批处理实现自动添加主DNS和副DNS信息,并删除多网卡的0.0.0.0默认路由,自动为多个网卡添加相应路由信息。
批处理内容如下:(保存为bat格式即可)
@echo off
echo 正在添加主DNS
netsh interface ip set dns “本地连接” static 202.106.0.20
echo 正在添加副DNS
netsh interface ip add dns “本地连接” 202.106.46.151
echo 正在删除默认路由
route delete 0.0.0.0
echo 正在第一条路由
route add -p 10.0.0.0 mask 255.0.0.0 10.28.127.254
echo 正在第二条路由
route add -p 0.0.0.0 mask 0.0.0.0 192.168.27.254