可以實現(xiàn)IP地址的錄入和載入,也就是說錄入一次后,以后用就可以直接載入不用手動輸入了。
沒什么版權(quán),轉(zhuǎn)載留名,畢竟就算是復制也是很多行,邏輯還是很難想清楚的。
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.系統(tǒng)登錄后自動鎖定 ┋
echo ┋ ┋
echo ┋ c.系統(tǒng)更換IP設(shè)置 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 用戶自動登陸設(shè)置完成……
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 西西的系統(tǒng)鎖定 /d %windir%\system32\run.vbs /f
del /f /q lock.bat
del /f /q run.vbs
echo 系統(tǒng)登錄后自動鎖定設(shè)置完成……
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=是否要加載現(xiàn)有的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% 子網(wǎng)掩碼" %windir%\xixi.ini >Z.txt
for /f "skip=2 tokens=3" %%Z in (Z.txt) do set mask=%%Z
echo 子網(wǎng)掩碼:%mask%
if exist M.txt del M.txt
find "%jname% 默認網(wǎng)關(guān)" %windir%\xixi.ini >M.txt
for /f "skip=2 tokens=3" %%M in (M.txt) do set gateway=%%M
echo 默認網(wǎng)關(guān):%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=加載完成!現(xiàn)在要開始設(shè)置?(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=請輸入子網(wǎng)掩碼(如:255.255.255.0):
set gateway=
set /p gateway=請輸入網(wǎng)關(guān)(如: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和子網(wǎng)掩碼設(shè)置完成........
netsh interface ip set address name="%name%" gateway=%gateway% gwmetric=0
echo 網(wǎng)關(guān)設(shè)置完成........
netsh interface ip set dns name="%name%" source=static addr=%dns1% register=PRIMARY
echo DNS1設(shè)置完成........
netsh interface ip add dns name="%name%" addr=%dns2%
echo DNS2設(shè)置完成........
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% 子網(wǎng)掩碼: %mask% >>%windir%\xixi.ini
echo %pname% 默認網(wǎng)關(guān): %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=需要用這套配置設(shè)置嗎?(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
您可能感興趣的文章:- Windows批處理雙擊切換IP地址方便、快捷
- Windows下用命令行修改IP地址的方法詳解(附批處理文件)
- SunTB編寫IP地址設(shè)置切換批處理
- 獲取外網(wǎng)IP地址的批處理代碼
- 配置IP地址的批處理代碼
- Windows XP中輕松獲取未使用的IP地址的批處理文件
- ip地址切換批處理腳本分享