• 装机自动化脚本介绍


    1、Rename the label of C

    1.1 根据批处理中ver的返回值判断系统类型
    ver | find "4.0." > NUL && goto win95 

    ver | find "4.10." > NUL && goto win98 

    ver | find "4.90." > NUL && goto win_me 

    ver | find "3.51." > NUL && goto win_Nt_3_5 

    ver | find "5.0." > NUL && goto win2000 

    ver | find "5.1." > NUL && goto win_xp 

    ver | find "5.2." > NUL && goto win2003 

    ver | find "6.0." > NUL && goto vista 

    ver | find "6.1." > NUL && goto win7 

    ver | find "6.2." > NUL && goto win8

    ver | find "6.3." > NUL && goto WinBlue

    ver | find "6.4." > NUL && goto Win9

    如个人PC批处理中执行ver,返回值"Microsoft Windows [版本 6.1.7600]",所以判断需要OS类型为Win7

    1.2 批处理中PROCESSOR_IDENTIFIER的返回值可判断OS位数(32bit or 64bit),方法如下:
    if /i "%PROCESSOR_IDENTIFIER:~0,3%"=="X86" (set bit=x86) ELSE set bit=x64

    1.3 Rename C盘盘符,方法如下:
    label c: %version_bit%(version_bit)

    2、Change partition letter

    2.1 方法如下:
    diskpart /s %letter_path%Change_letter.txt
    Change_letter.txt内容如下,
    select disk 0
    select volume 1
    assign letter d
    select volume 2
    assign letter e
    select volume 3
    assign letter f
    select volume 4
    assign letter g
    select volume 5
    assign letter h
    select volume 6
    assign letter i
    select volume 7
    assign letter j

    如上命令具有一定危险性,可能导致磁盘Volume丢失,所以执行之前作了判断,如果第一个磁盘volume值为C,第二个磁盘volume值为D,不执行此如上Change partition letter

    3、Set PC Name
    PC名字由用户手动输入,Eg:DL_E54301
    批处理在名字后面自动添加系统类型,如_W7x64
    所以最后汇总名字为DL_E54301_W7x64
    PC Name更改方法如下:
    wmic computersystem where caption='%computername%' rename %computer_name%

    4、Set Auto-Logon: admin/admin
    方法如下:
    REG ADD "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f >nul
    REG ADD "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultDomainName /t REG_SZ /d domainname /f >nul
    REG ADD "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d admin /f >nul
    REG ADD "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d admin /f >nul
    wmic useraccount set PasswordExpires=false

    5、Automatically Restart when BSOD
    方法如下:
    reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlCrashControl" /v AutoReboot /t REG_DWORD /d 1 /f >nul
    reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlCrashControl" /v AlwaysKeepMemoryDump /t REG_DWORD /d 1 /f >nul
    reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlCrashControl" /v CrashDumpEnabled /t REG_DWORD /d 2 /f >nul
    注:如果是XP系统,不执行如上操作。

    6、Show "My Computer" on Desktop
    方法如下:
    reg add HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsClassicStartMenu /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 0 /f

    reg add HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsNewStartPanel /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 0 /f

    reg add "HKEY_CURRENT_USERControl PanelDesktop" /v PaintDesktopVersion /t REG_DWORD /d 1 /f

    7、Turn off System Restor on all drivers
    方法如下:
    sysdm.cpl ,4
    注:此项是需要手动配置,但批处理会自动跳出需要配置的界面,算半自动化了。
    弄成半自动化是为了兼顾XP系统,原本的全自动方式命令XP下不支持。

    8、Set Network IP
    设置界面如下:
    echo ========================================
    echo Please choice IP segment
    echo [1].172.29.41.*
    echo [2].172.29.42.*
    echo [3].172.29.43.*
    echo [4].Skip and continues to the next item
    echo ========================================
    Set Choice=

    当Choice=1 ==> IP的格式为172.29.41.*
    当Choice=2 ==> IP的格式为172.29.42.*
    当Choice=3 ==> IP的格式为172.29.43.*
    当Choice=4 ==> 跳过IP设置,继续其他设置
    Choice值由用户键盘输入给定

    IP的最后一位也由用户给定,批处理同时做了合法值判断,要求大于等于0,小于等于255,否则要求重新输入。
    IP设置方法如下:
    netsh interface ip set address name="%Lan_name%" source=static address=%IP% mask=255.255.255.0 gateway=%Gateway%

    DNS设置方法如下:
    netsh interface ip set dns name="%Lan_name%" source=static address=172.29.17.10 register=primary

    备用DNS设置方法如下:
    netsh interface ip add dns name="%Lan_name%" address=172.29.17.11

    注:不同OS的LAN名字不同,批处理作了如下自动化判断,同时兼顾到中文、英文OS
    rem vista_os
    ver | find "6.0." > NUL && set Lan_name=Local Area Connection

    rem Win7_os 
    ver | find "7601" > NUL && set Lan_name=本地连接
    ver | find "7601" > NUL && ver | find "Version" > NUL && set Lan_name=Local Area Connection
    ver | find "7600" > NUL && set Lan_name=本地连接
    ver | find "7600" > NUL && ver | find "Version" > NUL && set Lan_name=Local Area Connection

    rem Win8_os
    ver | find "6.2." > NUL && set Lan_name=Ethernet

    rem Win8.1 and Win8.1_UP1
    ver | find "6.3." > NUL && set Lan_name=以太网
    ver | find "6.3." > NUL && set Lan_name=Ethernet

    rem Win9_os
    ver | find "6.4." > NUL && set Lan_name=以太网
    ver | find "6.4." > NUL && set Lan_name=Ethernet

    9、Change Explorer Options
    9.1 Disable Hide extensions for known file types.方法如下:
    reg add "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced" /v HideFileExt /t REG_DWORD /d 0 /f >nul

    9.2 Disable Remember each folder's view settings.方法如下:
    if "%version%"=="Vista" reg add "HKCUSoftwareClassesLocal SettingsSoftwareMicrosoftWindowsShellBagsAllFoldersshell" /v "FolderType" /t REG_SZ /d "NotSpecified" /f

    9.3 Enable Display the full path in the title bar.方法如下:
    reg add "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerCabinetState" /v FullPath /t REG_DWORD /d 1 /f >nul

    10、Change Display Options
    10.1 Change Screen to recommend resolution.
    显卡驱动成功安装后,系统自动给定合适分辨率,不需要脚本配置。

    10.2 Change text background to ESL(84 91 205).方法如下:
    reg add "HKEY_CURRENT_USERControl PanelColors" /v Window /t REG_SZ /d "204 232 207" /f && echo Text background change successful.

    10.3.Set Screen saver to none.方法如下:
    ver | find "5.1." > NUL && reg add "HKEY_CURRENT_USERControl PanelDesktop" /v SCRNSAVE.EXE /t REG_SZ /d " " /f && echo XP change successful.
    ver | find "6.0." > NUL && reg add "HKEY_CURRENT_USERControl PanelDesktop" /v SCRNSAVE.EXE /t REG_SZ /d " " /f && echo Vista change successful.

    11、Change Power Options
    11.1 Disable password when computer resume from standby and Set PC can hibernate
    本来可以通过powercfg /hibernate on解决,但W8x64上此命令执行无效,所以最后选择手动执行。
    同样,也是由批处理弹出相关设置界面,算半自动化。方法如下:
    control.exe /name Microsoft.PowerOptions /page pageGlobalSettings

    11.2 Change Power Options
    需要配置项目:
    DC、AC下monitor永不关闭;
    DC、AC下disk永不关闭;
    DC下60分钟后进入S3
    AC下永不进入S3;
    DC下120分钟后进入S4
    AC下永不进入S4;

    批处理实现方法如下:
    powercfg -Change -monitor-timeout-ac 0
    powercfg -Change -monitor-timeout-dc 0
    powercfg -Change -disk-timeout-ac 0
    powercfg -Change -disk-timeout-dc 0
    powercfg -Change -standby-timeout-ac 0
    powercfg -Change -standby-timeout-dc 60
    powercfg -Change -hibernate-timeout-ac 0
    powercfg -Change -hibernate-timeout-dc 120

    但如上设置只能更改当前选择的电源方案,台式机一般有三种balanced and high performance and power saver,笔记本模式更多,需要全部设置。方式如下:
    powercfg /l>>d:powercfg_name.txt
    ver | find "版本" > NUL && for /f "skip=3 eol=; tokens=3 delims= " %%i in (d:powercfg_name.txt) do (echo %%i && set Scheme_GUID=%%i) && powercfg /s %%i && call %change_power_path%set_power.bat
    for /f "skip=3 eol=; tokens=4 delims= " %%i in (d:powercfg_name.txt) do (echo %%i && set Scheme_GUID=%%i) && powercfg /s %%i && call %change_power_path%set_power.bat

    12、Turn off firewall
    方式如下:
    rem reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesSharedAccessParametersFirewallPolicyStandardProfile" /v EnableFirewall /t REG_DWORD /d "0" /f >nul
    rem reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesSharedAccessParametersFirewallPolicyPublicProfile" /v EnableFirewall /t REG_DWORD /d "0" /f >nul

    13、Turn off Auto updates
    reg add "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto Update" /v AUOptions /t REG_DWORD /d 1 /f

    14、Allow remote connection to this computer
    方式如下:
    reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f >nul

    15、Empty_Recycle
    采用第三方回收站清空工具,分32 and 64 bit
    方式如下:
    if /i "%PROCESSOR_IDENTIFIER:~0,3%"=="X86" (%Recycle_path%nircmdx86 ircmd.exe emptybin) ELSE (%Recycle_path%nircmdx64 ircmd.exe emptybin)

    16、Set Time Zone,Synchronize Date and Time with Internet Time Servers
    16.1 使用tzutil /l可列出目前计算机所有可用时区,china市区设置如下:
    if %result%==0 tzutil /s "China Standard Time" && echo Display the current time zone ID: && tzutil /g

    16.2 从互联网上获取、同步计算机日期、时间
    首先ping百度IP,判断网络是否连接
    ping 180.96.86.192 | findstr "ms" > NUL && set Network=1
    if "%Network%"=="1" (goto update_time) else (set Network=0 && echo Please connect to the Internet.)

    然后使用Tool将网络获取的时间保存在time.txt中,最后设置
    for /f "tokens=4,5,6 delims= " %%i in (%time_path% ime.txt) do set date=%%i & set time=%%j & set ma=%%k 

    注:PC本可以自动同步互联网时间,但有一个限制,网络时间与本地时间跨度不能超过两小时,否则无法自动更新到本地。而我们的本地时间,因时区不同已经跨度了一天,所以只有单个设置日期、时间。

    17、Active OS
    Enterprise版本采用公司正版激活,其他方式不作详细说明。

  • 相关阅读:
    元旦快乐,送大家一条水晶龙
    小随笔:利用Shader实现模型爆炸和沙粒化的效果
    小随笔:利用Shader给斯坦福兔子长毛和实现雪地效果
    #UnityTips# 2017.11.14
    微软Tech Summit 2017,微软携手Unity打造MR之夜
    FixedUpdate真的是固定的时间间隔执行吗?聊聊游戏定时器
    第9期Unity User Group Beijing图文报道:《Unity实战经验分享》
    利用GPU实现无尽草地的实时渲染
    大数据学习笔记01-HDFS-集群安装
    Guava学习笔记(三):集合
  • 原文地址:https://www.cnblogs.com/hester/p/5577136.html
Copyright © 2020-2023  润新知