
很多时候同一台电脑需要在不同的网络进行网络连接,但是每次都要重新设置ip地址、子网掩码、默认网关,每次修改多累呀。看着就让人头大!

所以我们就可以通过批处理文件(.bat)一键修改电脑ip地址啦。首先新建一个文本文档,输入以下代码
@echo off
echo.
echo 修改ip地址,1为自动获取ip地址,2为修改家里ip地址,3 为公司IP
echo.set sel=
set/p sel=请选择修改方式:
if "%sel%"=="1" goto auto
if "%sel%"=="2" goto home
if "%sel%"=="3" goto company
echo 您没有选择修改方式。
goto end
:auto
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip delete dns "本地连接" all
ipconfig /flushdns
ipconfig /all
goto end
:home
echo 正在更改IP地址,请稍等......
netsh interface ip set address name="本地连接" source=static addr=192.168.1.80 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=1
netsh interface ip set dns name="本地连接" source=static addr=202.102.192.68
netsh interface ip add dns name="本地连接" addr=202.102.199.68 index=2
ipconfig /flushdns
ipconfig /all
echo 更改IP地址完成!
goto end
:company
echo 正在更改IP地址,请稍等......
netsh interface ip set address name="本地连接" source=static addr=10.85.10.80 mask=255.255.255.0 gateway=10.85.10.253 gwmetric=1
netsh interface ip set dns name="本地连接" source=static addr=218.104.78.2
netsh interface ip add dns name="本地连接" addr=10.85.7.100 index=2
ipconfig /flushdns
ipconfig /all
goto end
:end
pause
保存以上代码,将.txt后缀改为.bat,以管理员权限运行即可(各位可根据实际情况在代码中对各自ip地址进行修改即可)。

当然好玩实用的的批处理代码还很多,如下所示:
1.关机:
shutdown -s -t 0
2.一分钟后关机:
shutdown /r
3.取消关机命令:
shutdown -a
4.从启资源管理器(可解决系统卡了,应用程序响应等问题):
taskkill /f /im explorer.exe & start explorer.exe
5.打开网站:
@echo off
start http://www.unsx.net/
6.清除垃圾文件,这其中包括临时文件、日志文件、磁盘检查文件、临时备份文件等:
@echo off
echo 正在清除系统垃圾文件,请稍等......
del /f /s /q %systemdrive%*.tmp
del /f /s /q %systemdrive%*._mp
del /f /s /q %systemdrive%*.log
del /f /s /q %systemdrive%*.gid
del /f /s /q %systemdrive%*.chk
del /f /s /q %systemdrive%*.old
del /f /s /q %systemdrive%recycled*.*
del /f /s /q %windir%*.bak
del /f /s /q %windir%prefetch*.*
rd /s /q %windir%temp & md %windir%temp
del /f /q %userprofile%cookies*.*
del /f /q %userprofile%recent*.*
del /f /s /q "%userprofile%Local SettingsTemporary Internet Files*.*"
del /f /s /q "%userprofile%Local SettingsTemp*.*"
del /f /s /q "%userprofile%recent*.*"
echo 清除系统LJ完成!
echo. & pause
以上,你都学废了吗?
我是尤尼可可,觉得有用请关注我,谢谢。
买空间上阿里云·限时·秒杀
买空间上腾讯云·爆品·秒杀