技巧:将机器IP地址前缀设置好后,发送到客户机使用
@ECHO OFF&PUSHD %~DP0 &TITLE 网络地址设置
mode con cols=60 lines=20
color fc
@echo off
set TempFile_Name=%SystemRoot%\System32\BatTestUACin_SysRt%Random%.batemp
echo %TempFile_Name%
( echo "BAT Test UAC in Temp" >%TempFile_Name% ) 1>nul 2>nul
if exist %TempFile_Name% (
echo 正在以管理员身份运行当前批处理,可以执行!
@ping -n 2 127.1 >nul 2>nul
del %TempFile_Name% 1>nul 2>nul
cls
goto :start
) else (
cls
echo 权限不足
)
pause
del %TempFile_Name% 1>nul 2>nul
echo 按空格键退出……
pause >nul
exit
:start
echo ============请输入数字选择下一步操作:
echo ============1:ip设置,子网掩码*255.255.255.0
echo ============2: 设置为DHCP自动获取ip
echo ============3:关于这个程序
echo ============0: 退出这个程序
echo *****安全软件(如360)会拦截该程序,请允许操作。
set /P var=":"
if %var%==1 goto ip10
if %var%==2 goto ipdhcp
if %var%==3 goto ip172
if %var%==0 goto quit
@ echo.
echo 年轻人。别乱搞
ping -n 2 127.1>nul
cls
goto start
:quit
exit
:ip10
cls
echo IP地址为:
set/p ip1=
echo 网关地址为:
set/p gw=
echo DNS地址为:
set/p dn2=
netsh interface ip set address name="本地连接" source=static addr=%ip1% mask=255.255.255.0 gateway=%gw% 1
netsh interface ip set dns name="本地连接" source=static addr=%dn2%
echo **IP设置为%ip1%,设置成功**
echo **检查您的配置是否可以上网**
echo ------------------------------------------
ping -n 5 127.1>nul
@ping www.baidu.com && goto :1t || goto :2t
exit
:1t
echo 恭喜,可以上网!
pause
cls
goto start
:2t
echo 注意,无法上网,请检查配置和网线!
pause
cls
goto start
:ip172
cls
echo -----------------------------------------------
echo **Huawei Net lab By:yjh 2015/10/18**
echo -----------------------------------------------
pause
cls
goto start
:ipdhcp
cls
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip delete dns "本地连接" all
ipconfig /flushdns
echo **IP设置为DHCP获取,设置成功**
echo ------------------------------------------
echo **检查您的配置是否可以上网**
echo ------------------------------------------
ping www.baidu.com && goto :1t || goto :2t
exit
:1t
echo 恭喜,可以上网!
pause
cls
goto start
:2t
echo 注意,无法上网,请检查配置和网线!
pause
cls
goto start