Batch process to implement fixed IP address system automatic login login Lock Computer _dos/bat

Source: Internet
Author: User
Tags configuration settings dns2 goto
Can realize the IP address input and load, that is, input once, after the use can be directly loaded without manual input.

No copyright, reprinted, after all, even if the copy is also a lot of lines, logic is still difficult to think clearly.
echo off
Mode con:cols=75 lines=20
Title CC's Small program power by---Fox-guy

: oder
Color 1d
Cls
REM menu item
Echo╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
Echo. ┋ cc for a long time did not do something, to do a small thing to share to everyone ┋
Echo. ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
Echo╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
Echo┋ is purely accidental ┋
Echo┋┋
Echo┋┋
Echo┋my Space Http://hi.baidu.com/xixilikexixi┋
Echo┋┋
Echo┋a. The user automatically logs on to B. Automatic locking after system login ┋
Echo┋┋
Echo┋c. System replacement IP Settings D. exit ┋
Echo┋┋
Echo┋┋
Echo╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝

Set c=
set/p c= Select and enter:
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= Please enter your user name:
Set pass=
set/p pass= Please enter your password:

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 User automatic login Setup Complete ...
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 cc's system lock/D%windir%\system32\run.vbs/f
del/f/q Lock.bat
del/f/q Run.vbs
Auto Lock Setup completes after echo system login ...
Ping-n 5 127.1>nul
Goto oder


: SetIP
: Oderip
Cls
REM menu item
Echo╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
Echo. ┋ cc for a long time did not do something, to do a small thing to share to everyone ┋
Echo. ╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
Echo╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
Echo┋ is purely accidental ┋
Echo┋┋
Echo┋┋
Echo┋my Space Http://hi.baidu.com/xixilikexixi┋
Echo┋┋
Echo┋a. Input IP configuration b. Load IP configuration ┋
Echo┋┋
Echo┋c. Remove all IP configurations D. Return to ┋
Echo┋┋
Echo┋┋
Echo╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝

Set c=
set/p c= Select and enter:
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 "Configure"%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 has no existing configuration! Please try typing. & ping-n 5 127.1>nul & Goto Oderip

: JZ1
Cls
Echo your current configuration has: & Type 1.txt
Echo.
Set j=
set/p j= do you want to load an existing IP configuration? (y/n):
if/i "%j%" = = "N" goto Oderip
Set Jname=
set/p jname= Please access the name of the IP configuration you want to load:

Echo.
Echo.
The configuration to be loaded by ECHO is:%jname%
If exist N.txt del N.txt
Find "%jname% connection name"%windir%\xixi.ini >n.txt
for/f "skip=2 tokens=3"%%n in (N.txt) do set name=%%n
echo Connection Name:%name%

If exist I.txt del I.txt
Find "%jname% IP address"%windir%\xixi.ini >i.txt
for/f "skip=2 tokens=3"%%i in (I.txt) do set ip=%%i
echo IP Address:%ip%

If exist Z.txt del Z.txt
Find "%jname% subnet mask"%windir%\xixi.ini >z.txt
for/f "skip=2 tokens=3"%%z in (Z.txt) do set mask=%%z
echo Subnet Mask:%mask%

If exist M.txt del M.txt
Find "%jname% default gateway"%windir%\xixi.ini >m.txt
for/f "skip=2 tokens=3"%%m in (M.txt) do set gateway=%%m
echo Default gateway:%gateway%

If exist S.txt del S.txt
Find "%jname% Preferred DNS"%windir%\xixi.ini >s.txt
for/f "skip=2 tokens=3"%%s in (S.txt) do set dns1=%%s
Echo Preferred dns:%dns1%

If exist B.txt del B.txt
Find "%jname% Alternate DNS"%windir%\xixi.ini >b.txt
for/f "skip=2 tokens=3"%%b in (B.txt) do set dns2=%%b
echo Standby 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= Load Complete! Do you want to start Setup now? (y/n):
if/i "%c%" = = "n" Goto Oderip
Goto Set

: LR
Cls
Set Pname=
set/p pname= Please enter a connection name (for example: Home IP configuration):
Set Name=
set/p name= Please enter a connection name (for example: local connection):
Set ip=
set/p ip= Please enter the IP address (e.g.: 192.168.0.2):
Set mask=
set/p mask= Please enter the subnet mask (for example: 255.255.255.0):
Set gateway=
set/p gateway= Please enter a gateway (for example: 192.168.0.1):
Set dns1=
set/p dns1= Please enter preferred DNS (for example: 61.128.128.68):
Set dns2=
set/p dns2= Please enter alternate DNS (for example: 202.202.145.5):

Echo.
Echo.
Does echo need to save this configuration? If you save the next use you can load this configuration directly without requiring manual input.
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 and subnet mask settings complete ....
netsh interface ip set address name= "%name%" gateway=%gateway% gwmetric=0
echo Gateway Setup Complete ...
netsh interface ip set DNS name= "%name%" source=static addr=%dns1% register=primary
echo DNS1 Setup Complete ...
netsh interface ip add dns name= "%name%" addr=%dns2%
echo DNS2 Setup Complete ...
netsh interface ip set wins name= "%name%" Source=static Addr=none

Goto Oderip

: Save
Cls
echo Configuration:%pname% >>%windir%\xixi.ini
echo%pname% Connection name:%name% >>%windir%\xixi.ini
echo%pname% IP address:%ip% >>%windir%\xixi.ini
echo%pname% Subnet mask:%mask% >>%windir%\xixi.ini
echo%pname% default gateway:%gateway% >>%windir%\xixi.ini
echo%pname% Preferred DNS:%dns1% >>%windir%\xixi.ini
echo%pname% Alternate DNS:%dns2% >>%windir%\xixi.ini
Echo. >>%windir%\xixi.ini
Echo Stored successfully ...
Ping-n 3 127.1>nul
Set s=
Does set/p s= need to use this set of configuration settings? (y/n):
if/i "%s%" = = "Y" goto set

Goto Oderip

:d Elset
Cls
del/f/q%windir%\xixi.ini
echo Delete Complete ...
Ping-n 5 127.1>nul
Goto Oderip
Special packaging provides downloads because the editor causes code distortion Ip_auto_suoding_jb51.rar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.