11号楼辅助设置.bat
11号楼辅助设置.bat
减轻为设置IP而输入一大堆数字的批处理。另附赠了一些如设置计算机名、简单优化服务、停用系统自带的管理员帐号(Administrator)等一系类方便“菜鸟”用户的贴心功能。
20080321更新:添加了“设置计算机名”的功能 ,细节调整。
20080427更新:增强了“辅助设置IP地址”的功能,可以支持任何语种的WinXP并加入了多网卡选择功能。
@ECHO OFF
setlocal EnableDelayedExpansion
title 11号楼辅助设置.bat
rem Author: Tunhsia <tunhsiaATgmail.com>, Update@20080427
:::::::::::::::::::::::::::主菜单:::::::::::::::::::::::
:MENU
COLOR 8A
CLS
ECHO.
ECHO.
ECHO.
ECHO. "11号楼辅助设置.bat"欢迎您的使用!
echo. (适用于各语种WinXP)
ECHO.
ECHO. 主菜单:
ECHO. 【1】辅助设置IP地址(仅适用于11号楼);
ECHO. 【2】添加一个自动登陆管理员并停用默认;
ECHO. 【3】简单优化服务以提升速度及加固安全;
ECHO. 【4】更改异常启动时磁盘错误检查等待时间;
ECHO. 【5】更改注册组织名、用户名与计算机名;
ECHO. 【a】关于此程序;
ECHO. 【q】退出。
ECHO.
set op=""
set /p op=请选择服务项目的数字号并回车[12345]:
if "%op%"=="1" (
goto :op1
) else if "%op%"=="2" (
goto :op2
) else if "%op%"=="3" (
goto :op3
) else if "%op%"=="4" (
goto :op4
) else if "%op%"=="5" (
goto :op5
) else if "%op%"=="a" (
goto about
) else if "%op%"=="q" (
goto :quit
) else (
goto :error
)
::::::::::::::::::::::::空输入处理:::::::::::::::::::::::
:error
cls
COLOR 8C
ECHO.
ECHO.
echo 您的输入有误,请输入1~5中的一个数字后回车!
echo 请按任意键返回主菜单!
pause >nul
goto :MENU
::::::::::::::::::::::设置IP:::::::::::::::::::::::::::
:op1
set adaptercount=0
set adapterlist=
for /f "usebackq tokens=1 delims=:" %%i in (`ipconfig /all ^| find ^"Ethernet adapter^"`) do (
set /a adaptercount+=1
set adaptername=%%i
set adapter!adaptercount!=!adaptername:~17!
set adapterlist=!adapterlist!!adaptercount!, !adaptername:~17!^&echo.
)
set i=Tunhsia
if %adaptercount% equ 1 (
set i=1
goto :CHOOSEADAPTERCOMPLETED
) else if %adaptercount% equ 0 (
echo 未发现可以配制的设备!请检查网卡是否被禁用。
ping 127.1 >nul
goto :MENU
)
echo.&echo 与该计算机相连的所有以太网卡列表如下
echo %adapterlist%
:CHOOSEADAPTERAGAIN
set/p i=请键入待配制网卡的数字序号:
if %i% geq 1 (if not %i% leq %adaptercount% goto :CHOOSEADAPTERAGAIN) else goto :CHOOSEADAPTERAGAIN
:CHOOSEADAPTERCOMPLETED
set adapter=!adapter%i%!
set i=Tunhsia
:INPUTIPAGAIN
set /p i=请输入您IP的最后一部分(如果您的IP地址是222.25.90.x,输入x即可):
if %i% geq 1 (if not %i% leq 254 goto :INPUTIPAGAIN) else goto :INPUTIPAGAIN
echo 正在设置IP、子网掩码与网关 …
netsh interface ip set address name="%adapter%" source=static addr=222.25.90.%i% mask=255.255.255.0 gateway=222.25.90.254 gwmetric=none
echo 正在设置首选DNS服务器 …
netsh interface ip set dns name="%adapter%" source=static addr=218.244.0.19
echo 正在设置备用DNS服务器 …
netsh interface ip add dns name="%adapter%" addr=61.134.1.4 index=2
goto :judge
:::::::::::::::::::::添加用户:::::::::::::::::::::::::
:op2
set user=
set /p user=请输入用户名(空输入将取消自动登陆):
if "%user%"=="" (
echo 正在取消自动登陆 …
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "AutoAdminLogon" /t reg_sz /d "0"
goto :judge
)
set /p pass=请输入密码:
echo 正在添加自动登陆管理员 …
net user "%user%" "%pass%" /add /comment:"这是一个具有管理员权限的自动登陆帐号。" /fullname:"%user%"
net localgroup administrators "%user%" /add
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "AutoAdminLogon" /t reg_sz /d "1"
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "DefaultUserName" /t reg_sz /d "%user%"
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "DefaultPassword" /t reg_sz /d "%pass%"
echo 正在停用系统自带的管理员用户 …
net user Administrator /active:no
goto judge
::::::::::::::::::优化服务::::::::::::::::::::::::
:op3
echo 正在优化服务 …
net stop "Error Reporting Service"
sc config ERSvc start= Disabled
net stop "Remote Registry"
sc config RemoteRegistry start= Disabled
net stop "Security Center"
sc config wscsvc start= Disabled
net stop "Task Scheduler"
sc config Schedule start= Disabled
net stop "Windows Time"
sc config W32Time start= Disabled
goto :judge
::::::::::::更改异常启动时磁盘错误检查等待时间:::::::
:op4
set AutoChkTimeOut=
set /p AutoChkTimeOut=请输入新的等待时间(默认10秒,建议改为3,空输入将设为0):
echo 正在更改异常启动时磁盘错误检查等待时间 …
echo y | reg add "HKLM/SYSTEM/ControlSet001/Control/Session Manager" /v "AutoChkTimeOut" /t REG_DWORD /d "%AutoChkTimeOut%"
goto :judge
::::::::::::更改注册组织名与用户名:::::::::::::::
:op5
set RegisteredOrganization=Tunhsia&set RegisteredOwner=Tunhsia&set ComputerName=Tunhsia
set /p RegisteredOrganization=请输入新的注册组织名:
set /p RegisteredOwner=请输入新的注册用户名:
set /p ComputerName=请输入新的计算机名:
echo 正在更改注册组织名、用户名与计算机名 …
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion" /v "RegisteredOrganization" /t reg_sz /d "%RegisteredOrganization%"
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion" /v "RegisteredOwner" /t reg_sz /d "%RegisteredOwner%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Control/ComputerName/ActiveComputerName" /v "ComputerName" /t reg_sz /d "%ComputerName%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Control/ComputerName/ComputerName" /v "ComputerName" /t reg_sz /d "%ComputerName%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Services/Tcpip/Parameters" /v "NV Hostname" /t reg_sz /d "%ComputerName%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Services/Tcpip/Parameters" /v "Hostname" /t reg_sz /d "%ComputerName%"
goto :judge
::::::::::::::::::::::::::关于::::::::::::::::::
:about
cls
echo.
echo.
echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★
echo ★ 关于 ★
echo. ★ ★
echo ★如有任何建议或Bug请Email至:liaodunxia@gmail.com ★
echo. ★ ★
echo ★ ★
echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★
echo.
echo.
set website= 欢迎访问我的博客:http://blog.csdn.net/t0nsha/
for /l %%i in (0,1,50) do call :website1 %%i
if %a% equ 50 goto :MENU
:website1
set/a a=%1
set/p=!website:~%a%,1!<nul
ping/n 1 127.1>nul
goto :eof
:::::::::::::::::::::::::退出::::::::::::::::::
:quit
cls
echo.
echo.
echo.
echo ----------
echo §谢谢使用!再见!§
echo ----------
ping -n 1 127.1 >nul & exit
::::::::::::::::::::::::judge:::::::::::::::::::::
:judge
if errorlevel 0 if not errorlevel 1 goto :success
goto :failure
:success
cls
color 8E
ECHO.
ECHO.
echo 恭喜,设置成功!按任意键返回主菜单。
pause>nul
goto :MENU
:failure
cls
COLOR 8C
ECHO.
ECHO.
echo Sorry,设置失败,请重试!按任意键返回主菜单。
pause>nul
goto :MENU
::::::::::::::::::::::THE END::::::::::::::::::::::
setlocal EnableDelayedExpansion
title 11号楼辅助设置.bat
rem Author: Tunhsia <tunhsiaATgmail.com>, Update@20080427
:::::::::::::::::::::::::::主菜单:::::::::::::::::::::::
:MENU
COLOR 8A
CLS
ECHO.
ECHO.
ECHO.
ECHO. "11号楼辅助设置.bat"欢迎您的使用!
echo. (适用于各语种WinXP)
ECHO.
ECHO. 主菜单:
ECHO. 【1】辅助设置IP地址(仅适用于11号楼);
ECHO. 【2】添加一个自动登陆管理员并停用默认;
ECHO. 【3】简单优化服务以提升速度及加固安全;
ECHO. 【4】更改异常启动时磁盘错误检查等待时间;
ECHO. 【5】更改注册组织名、用户名与计算机名;
ECHO. 【a】关于此程序;
ECHO. 【q】退出。
ECHO.
set op=""
set /p op=请选择服务项目的数字号并回车[12345]:
if "%op%"=="1" (
goto :op1
) else if "%op%"=="2" (
goto :op2
) else if "%op%"=="3" (
goto :op3
) else if "%op%"=="4" (
goto :op4
) else if "%op%"=="5" (
goto :op5
) else if "%op%"=="a" (
goto about
) else if "%op%"=="q" (
goto :quit
) else (
goto :error
)
::::::::::::::::::::::::空输入处理:::::::::::::::::::::::
:error
cls
COLOR 8C
ECHO.
ECHO.
echo 您的输入有误,请输入1~5中的一个数字后回车!
echo 请按任意键返回主菜单!
pause >nul
goto :MENU
::::::::::::::::::::::设置IP:::::::::::::::::::::::::::
:op1
set adaptercount=0
set adapterlist=
for /f "usebackq tokens=1 delims=:" %%i in (`ipconfig /all ^| find ^"Ethernet adapter^"`) do (
set /a adaptercount+=1
set adaptername=%%i
set adapter!adaptercount!=!adaptername:~17!
set adapterlist=!adapterlist!!adaptercount!, !adaptername:~17!^&echo.
)
set i=Tunhsia
if %adaptercount% equ 1 (
set i=1
goto :CHOOSEADAPTERCOMPLETED
) else if %adaptercount% equ 0 (
echo 未发现可以配制的设备!请检查网卡是否被禁用。
ping 127.1 >nul
goto :MENU
)
echo.&echo 与该计算机相连的所有以太网卡列表如下
echo %adapterlist%
:CHOOSEADAPTERAGAIN
set/p i=请键入待配制网卡的数字序号:
if %i% geq 1 (if not %i% leq %adaptercount% goto :CHOOSEADAPTERAGAIN) else goto :CHOOSEADAPTERAGAIN
:CHOOSEADAPTERCOMPLETED
set adapter=!adapter%i%!
set i=Tunhsia
:INPUTIPAGAIN
set /p i=请输入您IP的最后一部分(如果您的IP地址是222.25.90.x,输入x即可):
if %i% geq 1 (if not %i% leq 254 goto :INPUTIPAGAIN) else goto :INPUTIPAGAIN
echo 正在设置IP、子网掩码与网关 …
netsh interface ip set address name="%adapter%" source=static addr=222.25.90.%i% mask=255.255.255.0 gateway=222.25.90.254 gwmetric=none
echo 正在设置首选DNS服务器 …
netsh interface ip set dns name="%adapter%" source=static addr=218.244.0.19
echo 正在设置备用DNS服务器 …
netsh interface ip add dns name="%adapter%" addr=61.134.1.4 index=2
goto :judge
:::::::::::::::::::::添加用户:::::::::::::::::::::::::
:op2
set user=
set /p user=请输入用户名(空输入将取消自动登陆):
if "%user%"=="" (
echo 正在取消自动登陆 …
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "AutoAdminLogon" /t reg_sz /d "0"
goto :judge
)
set /p pass=请输入密码:
echo 正在添加自动登陆管理员 …
net user "%user%" "%pass%" /add /comment:"这是一个具有管理员权限的自动登陆帐号。" /fullname:"%user%"
net localgroup administrators "%user%" /add
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "AutoAdminLogon" /t reg_sz /d "1"
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "DefaultUserName" /t reg_sz /d "%user%"
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Winlogon" /v "DefaultPassword" /t reg_sz /d "%pass%"
echo 正在停用系统自带的管理员用户 …
net user Administrator /active:no
goto judge
::::::::::::::::::优化服务::::::::::::::::::::::::
:op3
echo 正在优化服务 …
net stop "Error Reporting Service"
sc config ERSvc start= Disabled
net stop "Remote Registry"
sc config RemoteRegistry start= Disabled
net stop "Security Center"
sc config wscsvc start= Disabled
net stop "Task Scheduler"
sc config Schedule start= Disabled
net stop "Windows Time"
sc config W32Time start= Disabled
goto :judge
::::::::::::更改异常启动时磁盘错误检查等待时间:::::::
:op4
set AutoChkTimeOut=
set /p AutoChkTimeOut=请输入新的等待时间(默认10秒,建议改为3,空输入将设为0):
echo 正在更改异常启动时磁盘错误检查等待时间 …
echo y | reg add "HKLM/SYSTEM/ControlSet001/Control/Session Manager" /v "AutoChkTimeOut" /t REG_DWORD /d "%AutoChkTimeOut%"
goto :judge
::::::::::::更改注册组织名与用户名:::::::::::::::
:op5
set RegisteredOrganization=Tunhsia&set RegisteredOwner=Tunhsia&set ComputerName=Tunhsia
set /p RegisteredOrganization=请输入新的注册组织名:
set /p RegisteredOwner=请输入新的注册用户名:
set /p ComputerName=请输入新的计算机名:
echo 正在更改注册组织名、用户名与计算机名 …
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion" /v "RegisteredOrganization" /t reg_sz /d "%RegisteredOrganization%"
echo y | reg add "HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion" /v "RegisteredOwner" /t reg_sz /d "%RegisteredOwner%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Control/ComputerName/ActiveComputerName" /v "ComputerName" /t reg_sz /d "%ComputerName%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Control/ComputerName/ComputerName" /v "ComputerName" /t reg_sz /d "%ComputerName%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Services/Tcpip/Parameters" /v "NV Hostname" /t reg_sz /d "%ComputerName%"
echo y | reg add "HKLM/SYSTEM/ControlSet001/Services/Tcpip/Parameters" /v "Hostname" /t reg_sz /d "%ComputerName%"
goto :judge
::::::::::::::::::::::::::关于::::::::::::::::::
:about
cls
echo.
echo.
echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★
echo ★ 关于 ★
echo. ★ ★
echo ★如有任何建议或Bug请Email至:liaodunxia@gmail.com ★
echo. ★ ★
echo ★ ★
echo ★★★★★★★★★★★★★★★★★★★★★★★★★★★
echo.
echo.
set website= 欢迎访问我的博客:http://blog.csdn.net/t0nsha/
for /l %%i in (0,1,50) do call :website1 %%i
if %a% equ 50 goto :MENU
:website1
set/a a=%1
set/p=!website:~%a%,1!<nul
ping/n 1 127.1>nul
goto :eof
:::::::::::::::::::::::::退出::::::::::::::::::
:quit
cls
echo.
echo.
echo.
echo ----------
echo §谢谢使用!再见!§
echo ----------
ping -n 1 127.1 >nul & exit
::::::::::::::::::::::::judge:::::::::::::::::::::
:judge
if errorlevel 0 if not errorlevel 1 goto :success
goto :failure
:success
cls
color 8E
ECHO.
ECHO.
echo 恭喜,设置成功!按任意键返回主菜单。
pause>nul
goto :MENU
:failure
cls
COLOR 8C
ECHO.
ECHO.
echo Sorry,设置失败,请重试!按任意键返回主菜单。
pause>nul
goto :MENU
::::::::::::::::::::::THE END::::::::::::::::::::::