Installation Automation Script Introduction

Source: Internet
Author: User
Tags echo display eol time zones

1. Rename the label of C

1.1 Judging the system type based on the return value of ver in batch processing
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

For example, the PC batch is executed in Ver, the return value "Microsoft Windows [version 6.1.7600]", so the decision requires OS type Win7

1.2 The return value of Processor_identifier in batch processing can determine the number of OS bits (32bit or 64bit), as follows:
if/i "%processor_identifier:~0,3%" = = "X86" (set bit=x86) ELSE set bit=x64

1.3 Rename C drive letter, the method is as follows:
Label C:%version_bit% (Version_bit)

2. Change partition

The 2.1 methods are as follows:
DISKPART/S%letter_path%\change_letter.txt
Change_letter.txt content is as follows,
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

If the above command is dangerous, it may cause disk volume to be lost, so it is determined before execution, if the first disk volume value is C, the second disk volume value is D, do not perform this as change partition

3. Set PC Name
The PC name is entered manually by the user, eg:dl_e54301
Batching automatically adds a system type after the name, such as _w7x64
So the final summary name is dl_e54301_w7x64
The PC name change method is as follows:
WMIC ComputerSystem where caption= '%computername% ' rename%computer_name%

4. Set Auto-logon:admin/admin
Here's how:
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"/V autoadminlogon/t reg_sz/d/F >nul
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"/V defaultdomainname/t reg_sz/d domainname/f > Nul
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"/V defaultusername/t reg_sz/d admin/f >nul
REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"/V defaultpassword/t reg_sz/d admin/f >nul
WMIC UserAccount Set Passwordexpires=false

5, automatically Restart when BSOD
Here's how:
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl"/V autoreboot/t reg_dword/d/F >nul
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl"/V alwayskeepmemorydump/t reg_dword/d/F >nul
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl"/V crashdumpenabled/t reg_dword/d 2/f > Nul
Note: If it is an XP system, do not perform the above operation.

6. Show "My Computer" on Desktop
Here's how:
Reg ADD hkcu\software\microsoft\windows\currentversion\explorer\hidedesktopicons\classicstartmenu/v { 20d04fe0-3aea-1069-a2d8-08002b30309d}/T reg_dword/d 0/f

Reg ADD hkcu\software\microsoft\windows\currentversion\explorer\hidedesktopicons\newstartpanel/v { 20d04fe0-3aea-1069-a2d8-08002b30309d}/T reg_dword/d 0/f

REG ADD "HKEY_CURRENT_USER\Control Panel\Desktop"/V paintdesktopversion/t reg_dword/d/F

7, Turn off System restor on all drivers
Here's how:
Sysdm.cpl, 4
Note: This is required for manual configuration, but batching automatically jumps out of the interface that needs to be configured, and is semi-automated.
Semi-automatic is to take into account the XP system, the original automatic mode command XP is not supported.

8. Set Network IP
The Setup interface is as follows:
Echo ========================================
Echo 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=

When the choice=1 ==> IP format is 172.29.41.*
When the choice=2 ==> IP format is 172.29.42.*
When the choice=3 ==> IP format is 172.29.43.*
When choice=4 ==> skips IP settings, continue with other settings
The choice value is entered by the user keyboard for the given

The last of the IP is also given by the user, batch processing at the same time to make a legal value, the requirement is greater than or equal to 0, less than or equal to 255, otherwise requires re-input.
The IP setting method is as follows:
netsh interface ip set address name= "%lan_name%" source=static address=%ip% mask=255.255.255.0 gateway=%gateway%

The DNS setting method is as follows:
netsh interface ip set DNS name= "%lan_name%" source=static address=172.29.17.10 register=primary

The alternate DNS setting method is as follows:
netsh interface ip add dns name= "%lan_name%" address=172.29.17.11

Note: The LAN name of different OS is different, the batch processing makes the following automatic judgment, simultaneously takes into account the Chinese, the English 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= Local Area Connection
ver | Find "7601" > NUL && ver | Find "Version" > NUL && set lan_name=local area Connection
ver | Find "7600" > NUL && set lan_name= Local Area Connection
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= Ethernet
ver | Find "6.3." > NUL && set lan_name=ethernet

REM Win9_os
ver | Find "6.4." > NUL && set lan_name= Ethernet
ver | Find "6.4." > NUL && set lan_name=ethernet

9. Change Explorer Options
9.1 Disable Hide Extensions for known file types. The method is as follows:
REG ADD "hkey_current_user\software\microsoft\windows\currentversion\explorer\advanced"/V hidefileext/t REG_DWORD/ D 0/f >nul

9.2 Disable Remember Each folder ' s view settings. method as follows:
If "%version%" = = "Vista" reg add "HKCU\Software\Classes\Local settings\software\microsoft\windows\shell\bags\ Allfolders\shell "/V" foldertype "/t reg_sz/d" notspecified "/F

9.3 Enable Display The full path in the title bar. The method is as follows:
REG ADD "hkey_current_user\software\microsoft\windows\currentversion\explorer\cabinetstate"/V fullpath/t REG_DWORD /d/F >nul

10. Change Display Options
10.1 Change screens to recommend resolution.
After the graphics driver is successfully installed, the system automatically gives the appropriate resolution without the need for script configuration.

10.2 Change text background to ESL (84 91 205). The method is as follows:
REG ADD "HKEY_CURRENT_USER\Control panel\colors"/V window/t reg_sz/d "204 232 207"/F && echo Text background C Hange successful.

10.3.Set screen saver to None. The method is as follows:
ver | Find "5.1." > NUL && reg add "HKEY_CURRENT_USER\Control Panel\Desktop"/V scrnsave. exe/t reg_sz/d ""/F && echo XP change successful.
ver | Find "6.0." > NUL && reg add "HKEY_CURRENT_USER\Control Panel\Desktop"/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
It could have been resolved by powercfg/hibernate on, but the command execution was invalid on w8x64, so it was chosen manually.
Similarly, the batch processing popup related Settings interface, is semi-automatic. Here's how:
Control.exe/name Microsoft.poweroptions/page pageglobalsettings

11.2 Change Power Options
Configuration items are required:
Monitor never shuts down in DC or AC;
DC, AC disk never shut down;
DC enters S3 60 minutes after the
Never enter S3 under AC;
DC enters S4 120 minutes after the
Never enter S4 under AC;

The batch implementation method is as follows:
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

However, if the setting above only changes the current selection of power schemes, the desktop generally has three balanced and high performance and power saver, notebook mode more, need to set all. Here's how:
Powercfg/l>>d:\powercfg_name.txt
ver | Find "Version" > 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 & amp;& 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 & amp;& Call%change_power_path%\set_power.bat

12, Turn off firewall
Here's how:
REM REG ADD "hkey_local_machine\system\currentcontrolset\services\sharedaccess\parameters\firewallpolicy\ Standardprofile "/V enablefirewall/t reg_dword/d" 0 "/F >nul
REM REG ADD "hkey_local_machine\system\currentcontrolset\services\sharedaccess\parameters\firewallpolicy\ Publicprofile "/V enablefirewall/t reg_dword/d" 0 "/F >nul

13. Turn Off Auto Updates
REG ADD "Hkey_local_machine\software\microsoft\windows\currentversion\windowsupdate\auto Update"/V auoptions/t REG_ dword/d

14. Allow remote connection to this computer
Here's how:
REG ADD "hkey_local_machine\system\currentcontrolset\control\terminal Server"/V fdenytsconnections/t reg_dword/d 0/f >nul

15, Empty_recycle
Use a third-party Recycle Bin emptying tool, divided by
Here's how:
if/i "%processor_identifier:~0,3%" = = "X86" (%recycle_path%nircmdx86\nircmd.exe emptybin) ELSE (%recycle_path% Nircmdx64\nircmd.exe Emptybin)

16. Set Time Zone,synchronize Date and time with Internet time Servers
16.1 using TZUTIL/L to list all available time zones for the current computer, the China urban settings are as follows:
If%result%==0 tzutil/s "China Standard Time" && Echo Display the current time zone ID: && tzutil/g

16.2 Getting and synchronizing computer date and time from the Internet
First ping Baidu IP, determine whether the network is connected
Ping 180.96.86.192 | Findstr "MS" > NUL && set network=1
If "%network%" = = "1" (Goto update_time) Else (set network=0 && echo Guest connect to the Internet.)

Then use the tool to save the time of the network acquisition in Time.txt, and finally set
for/f "tokens=4,5,6 delims="%%i in (%time_path%\time.txt) do set date=%%i & Set Time=%%j & Set Ma=%%k

Note: PC can automatically synchronize Internet time, but there is a limit, network time and local time span can not exceed two hours, otherwise cannot be automatically updated to local. And our local time, because the time zone is different has spanned the day, so only a single set date, time.

17. Active OS
Enterprise version is activated by the company's original, other methods do not elaborate.

Installation Automation Script Introduction

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.