欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

批处理实现固定IP地址 系统自动登录 登录后锁定计算机

程序员文章站 2022-06-23 18:53:41
可以实现ip地址的录入和载入,也就是说录入一次后,以后用就可以直接载入不用手动输入了。 没什么版权,转载留名,毕竟就算是复制也是很多行,逻辑还是很难想清楚的。echo of...
可以实现ip地址的录入和载入,也就是说录入一次后,以后用就可以直接载入不用手动输入了。

没什么版权,转载留名,毕竟就算是复制也是很多行,逻辑还是很难想清楚的。
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
因编辑器导致代码变形,特打包提供下载