批处理实现固定IP地址 批处理实现固定IP地址 系统自动登录 登录后锁定计算机
人气:0没什么版权,转载留名,毕竟就算是复制也是很多行,逻辑还是很难想清楚的。
echo off
mode con: cols=75 lines=20
title 西西的小程序 Power By --- Fox-Guy
:oder
color 1d
cls
rem 菜单项
echo ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
echo. ┋ 西西很久没做东西了,做一个小东西分享给大家 ┋
echo. ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
echo ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
echo ┋ 纯属偶然 ┋
echo ┋ ┋
echo ┋ ┋
echo ┋ MY Space http://hi.baidu.com/xixilikexixi ┋
echo ┋ ┋
echo ┋ a.用户自动登录 b.系统登录后自动锁定 ┋
echo ┋ ┋
echo ┋ c.系统更换IP设置 d.退出 ┋
echo ┋ ┋
echo ┋ ┋
echo ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
set c=
set /p c=选择并回车:
if /I "%c%"=="a" goto auto
if /I "%c%"=="b" goto lock
if /I "%c%"=="c" goto setip
if /I "%c%"=="d" goto exit
:auto
cls
set user=
set /p user=请输入用户名:
set pass=
set /p pass=请输入密码:
if exist auto.reg del auto.reg
echo Windows Registry Editor Version 5.00 >auto.reg
echo. >>auto.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] >>auto.reg
echo "DefaultUserName"="%user%" >>auto.reg
echo "AutoAdminLogon"="1" >>auto.reg
echo "Defaultpassword"="%pass%" >>auto.reg
regedit /s auto.reg
del /f /q auto.reg
echo 用户自动登陆设置完成……
ping -n 5 127.1>nul
goto oder
:lock
if exist lock.bat del lock.bat
if exist run.vbs del run.vbs
echo @echo off >lock.bat
echo rundll32 user32.dll LockWorkStation >>lock.bat
echo exit >>lock.bat
echo DIM objShell >run.vbs
echo set objShell=wscript.createObject("wscript.shell") >>run.vbs
echo iReturn=objShell.Run("lock.bat",0, TRUE) >>run.vbs
copy lock.bat %windir%\system32\ /y
copy run.vbs %windir%\system32\ /y
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v 西西的系统锁定 /d %windir%\system32\run.vbs /f
del /f /q lock.bat
del /f /q run.vbs
echo 系统登录后自动锁定设置完成……
ping -n 5 127.1>nul
goto oder
:setip
:oderip
cls
rem 菜单项
echo ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
echo. ┋ 西西很久没做东西了,做一个小东西分享给大家 ┋
echo. ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
echo ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
echo ┋ 纯属偶然 ┋
echo ┋ ┋
echo ┋ ┋
echo ┋ MY Space http://hi.baidu.com/xixilikexixi ┋
echo ┋ ┋
echo ┋ a.录入IP配置 b.加载IP配置 ┋
echo ┋ ┋
echo ┋ c.删除所有IP配置 d.返回 ┋
echo ┋ ┋
echo ┋ ┋
echo ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
set c=
set /p c=选择并回车:
if /I "%c%"=="a" goto lr
if /I "%c%"=="b" goto jz
if /I "%c%"=="c" goto delset
if /I "%c%"=="d" goto oder
:jz
cls
if exist xixi.txt del xixi.txt
if exist 1.txt del 1.txt
find "配置" %windir%\xixi.ini >xixi.txt
FOR /F "eol=; tokens=2 delims=:" %%i in (xixi.txt) do (
echo %%i>>1.txt
)
del /f /q xixi.txt
if exist 1.txt (goto jz1) ELSE echo 目前没有已有配置!请尝试录入。 & ping -n 5 127.1>nul & goto oderip
:jz1
cls
echo 您目前有的配置有: & type 1.txt
echo.
set j=
set /p j=是否要加载现有的IP配置?(Y/N):
if /I "%j%"=="N" goto oderip
set jname=
set /p jname=请出入你要加载的IP配置的名字:
echo.
echo.
echo 要加载的配置是:%jname%
if exist N.txt del N.txt
find "%jname% 连接名字" %windir%\xixi.ini >N.txt
for /f "skip=2 tokens=3" %%N in (N.txt) do set name=%%N
echo 连接名字:%name%
if exist I.txt del I.txt
find "%jname% IP地址" %windir%\xixi.ini >I.txt
for /f "skip=2 tokens=3" %%I in (I.txt) do set ip=%%I
echo IP地址:%ip%
if exist Z.txt del Z.txt
find "%jname% 子网掩码" %windir%\xixi.ini >Z.txt
for /f "skip=2 tokens=3" %%Z in (Z.txt) do set mask=%%Z
echo 子网掩码:%mask%
if exist M.txt del M.txt
find "%jname% 默认网关" %windir%\xixi.ini >M.txt
for /f "skip=2 tokens=3" %%M in (M.txt) do set gateway=%%M
echo 默认网关:%gateway%
if exist S.txt del S.txt
find "%jname% 首选DNS" %windir%\xixi.ini >S.txt
for /f "skip=2 tokens=3" %%S in (S.txt) do set dns1=%%S
echo 首选DNS:%dns1%
if exist B.txt del B.txt
find "%jname% 备用DNS" %windir%\xixi.ini >B.txt
for /f "skip=2 tokens=3" %%B in (B.txt) do set dns2=%%B
echo 备用DNS:%dns2%
del /f /q 1.txt
del /f /q N.TXT
del /f /q I.TXT
del /f /q Z.TXT
del /f /q M.TXT
del /f /q S.TXT
del /f /q B.TXT
echo.
echo.
set c=
set /p c=加载完成!现在要开始设置?(Y/N):
if /I "%c%"=="n" goto oderip
goto set
:lr
cls
set pname=
set /p pname=请输入连接名(如:家里的IP配置):
set name=
set /p name=请输入连接名(如:本地连接):
set ip=
set /p ip=请输入IP地址(如:192.168.0.2):
set mask=
set /p mask=请输入子网掩码(如:255.255.255.0):
set gateway=
set /p gateway=请输入网关(如:192.168.0.1):
set dns1=
set /p dns1=请输入首选DNS(如:61.128.128.68):
set dns2=
set /p dns2=请输入备用DNS(如:202.202.145.5):
echo.
echo.
echo 需要保存这个配置吗?如果保存下次使用可以直接加载这个配置无需手动输入。
set s=
set /p s=(Y/N):
if /I "%s%"=="Y" goto save
:set
cls
netsh interface ip set address name="%name%" source=static addr=%ip% mask=%mask%
echo IP和子网掩码设置完成........
netsh interface ip set address name="%name%" gateway=%gateway% gwmetric=0
echo 网关设置完成........
netsh interface ip set dns name="%name%" source=static addr=%dns1% register=PRIMARY
echo DNS1设置完成........
netsh interface ip add dns name="%name%" addr=%dns2%
echo DNS2设置完成........
netsh interface ip set wins name="%name%" source=static addr=none
goto oderip
:save
cls
echo 配置: %pname% >>%windir%\xixi.ini
echo %pname% 连接名字: %name% >>%windir%\xixi.ini
echo %pname% IP地址: %ip% >>%windir%\xixi.ini
echo %pname% 子网掩码: %mask% >>%windir%\xixi.ini
echo %pname% 默认网关: %gateway% >>%windir%\xixi.ini
echo %pname% 首选DNS: %dns1% >>%windir%\xixi.ini
echo %pname% 备用DNS: %dns2% >>%windir%\xixi.ini
echo. >>%windir%\xixi.ini
echo 储存成功……
ping -n 3 127.1>nul
set s=
set /p s=需要用这套配置设置吗?(Y/N):
if /I "%s%"=="Y" goto set
goto oderip
:delset
cls
del /f /q %windir%\xixi.ini
echo 删除完成……
ping -n 5 127.1>nul
goto oderip
因编辑器导致代码变形,特打包提供下载ip_auto_suoding_jb51.rar
加载全部内容