Hướng dẫn cấu hình sao chép và thực thi tệp tự động trong suốt quá trình cài đặt Windows

Trong Windows 10 hay các hệ điều hành Windows trở về trước Microsoft đã lập trình cài đặt tự động sao chép thư mục hoặc tập tin từ usb/dvd cài đặt đến đường dẫn phân vùng hệ thống hoặc các thư mục trong phân vùng đó thông qua một thư mục có tên $OEM$ nằm trong thư mục sources của usb/dvd.

Bạn lưu ý thư mục $OEM$ sẽ không có sẵn trong thư mục sources của bộ cài ISO mà phải tạo mới và lưu trong đó để trong quá trình cài đặt Windows sẽ tự tìm đến thư mục $OEM$ của usb/dvd mà dựa vào đó sao chép các thư mục hoặc tập tin mà bạn đặt trong thư mục này.

Dưới đây mình sẽ trình bày cấu trúc đường dẫn của nó trong thư mục $OEM$

Đầu tiên để sao chép được thì bạn phải tạo mới thư mục tên $OEM$ trong thư mục sources trước. Trong thư mục này có 4 thư mục chính mà bạn cần biết đó là các thư mục $$$1$docs$progs

Giải thích các thư mục trên như sau:

$1: đường dẫn đến phân vùng hệ thống thường là ổ C hoặc %system%
$$: đường dẫn đến thư mục Windows trong ổ C viết theo đường dẫn là C:Windows hoặc %windir%
$docs: đường dẫn đến thư mục Documents trong ổ C
$progs: đường dẫn đến thư mục Program File trong ổ C

Như vậy nếu muốn thiết lập thư mục hoặc tập tin cần sao chép đến đường dẫn trên thì bạn làm như sau:

Ví dụ mình muốn sao chép thư mục Packages trong đó có lưu các bản cập nhật mình sẽ đặt thư mục này vào thư mục $1

Mình muốn sao chép các tệp vào thư mục INF và thư mục Panther của thư mục Windows trong ổ C do đó mình sẽ tạo mới các thư mục INFPanther trong thư mục $$ và trong thư mục INF mình đặt tệp dạng driver .inf và thư mục Panther mình đặt tập tin cài đặt tự động Unattend.xml

Mở rộng giả sử mình muốn sao chép tệp ảnh vào thư mục oobe trong thư mục System32 của thư mục Widows theo đường dẫn C:WindowsSystem32oobe mình sẽ tạo mới thư mục System32 vào thư mục $$ và trong thư mục System32 mình lại tạo mới thư mục tên oobe và lưu tệp hình ảnh vào thư mục này

Mình sẽ mô tả bằng sơ đồ hình cây dưới đây cho bạn dễ hình dung

Copy

usb drive

    sources

          $OEM$

              $$

                 INF

                     oem1.inf

                     oem2.inf

                 Panther

                     Unattend.xml

                 Setup

                     Scripts

                         SetupComplete.cmd

                 System32

                     oobe

                         OEMWallapaper.png

                         OEMLogo.bmp

                 S1

                     Packages

                         microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab

                         winrar-x64.exe

                     Users

                         Default

                             AppData

                                 Local

                                     Microsoft

                                         Windows

                                             Shell

                                                 LayoutModification.xml

                             Desktop

                                 Windows 10 Tweaker

                                     Windows_10_Tweaker.cmd

Mục đích chính khi sao chép các thư mục này là để thưc thi quá trình trong khi cài đặt, giả sử bạn muốn cài đặt driver tự động thì bạn phải sao chép các tệp driver (.inf) vào thư mục INF của thư mục Windows, bạn muốn sau khi cài đặt sẽ đăng nhập tự động bỏ qua các bước thiết lập tài khoản thì bạn cần phải có tập tin cấu hình tự động Unattend.xml trong thư mục Panther của thư mục Windows.

Hướng dẫn thực thi tệp trong suốt quá trình cài đặt

Đầu tiên mình sẽ thực thi các tệp trong thư mục Packages trong đó có lưu 2 tệp:

Copy

microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab

winrar-x64.exe

Như vậy mình cần sử dụng lệnh command để thực thi 2 tệp này và mình sẽ viết lệnh trong nội dung của tệp SetupComplete.cmd lưu trong thư mục Scripts

Copy

Dism /Online /Add-Package /PackagePath:C:Packagesmicrosoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab /Quiet /NoRestart

Start /wait C:Packageswinrar-x64.exe /s

Kết hợp mình sẽ gỡ bỏ ứng dụng Feedback Hub bằng lệnh sau áp dụng Windows 10, version 1809

Copy

Dism /Online /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsFeedbackHub_2018.822.2.0_neutral_~_8wekyb3d8bbwe

Danh sách PackageName của ứng dụng thuộc StoreApps trong Windows 10, version 1809

Copy

PackageName

-----------

Microsoft.BingWeather_4.26.12153.0_neutral_~_8wekyb3d8bbwe

Microsoft.DesktopAppInstaller_2018.720.2137.0_neutral_~_8wekyb3d8bbwe

Microsoft.GetHelp_10.1706.12332.0_neutral_~_8wekyb3d8bbwe

Microsoft.Getstarted_6.14.12121.1000_neutral_~_8wekyb3d8bbwe

Microsoft.HEIFImageExtension_1.0.11792.0_x64__8wekyb3d8bbwe

Microsoft.Messaging_2018.727.1430.0_neutral_~_8wekyb3d8bbwe

Microsoft.Microsoft3DViewer_5.1807.6012.1000_neutral_~_8wekyb3d8bbwe

Microsoft.MicrosoftOfficeHub_2018.614.804.1000_neutral_~_8wekyb3d8bbwe

Microsoft.MicrosoftSolitaireCollection_4.2.8172.0_neutral_~_8wekyb3d8bbwe

Microsoft.MicrosoftStickyNotes_2.1.18.0_neutral_~_8wekyb3d8bbwe

Microsoft.MixedReality.Portal_2000.18090.1131.0_neutral_~_8wekyb3d8bbwe

Microsoft.MSPaint_5.1809.1017.0_neutral_~_8wekyb3d8bbwe

Microsoft.Office.OneNote_16001.10730.20033.0_neutral_~_8wekyb3d8bbwe

Microsoft.OneConnect_5.1807.1991.1000_neutral_~_8wekyb3d8bbwe

Microsoft.People_2018.905.522.0_neutral_~_8wekyb3d8bbwe

Microsoft.Print3D_3.1.2612.0_neutral_~_8wekyb3d8bbwe

Microsoft.ScreenSketch_2018.817.530.0_neutral_~_8wekyb3d8bbwe

Microsoft.SkypeApp_14.30.73.0_neutral_~_kzf8qxf38zg5c

Microsoft.StorePurchaseApp_11808.1001.413.0_neutral_~_8wekyb3d8bbwe

Microsoft.VP9VideoExtensions_1.0.12611.0_x64__8wekyb3d8bbwe

Microsoft.Wallet_2.2.18179.0_neutral_~_8wekyb3d8bbwe

Microsoft.WebMediaExtensions_1.0.12341.0_neutral_~_8wekyb3d8bbwe

Microsoft.WebpImageExtension_1.0.11551.0_x64__8wekyb3d8bbwe

Microsoft.Windows.Photos_2018.18081.14710.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsAlarms_2018.904.600.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsCalculator_2018.904.536.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsCamera_2018.426.90.1000_neutral_~_8wekyb3d8bbwe

microsoft.windowscommunicationsapps_16005.10827.20137.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsFeedbackHub_2018.822.2.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsMaps_2018.817.1649.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsSoundRecorder_2018.904.546.0_neutral_~_8wekyb3d8bbwe

Microsoft.WindowsStore_11809.1001.813.0_neutral_~_8wekyb3d8bbwe

Microsoft.Xbox.TCUI_1.11.29001.0_neutral_~_8wekyb3d8bbwe

Microsoft.XboxApp_44.44.7002.0_neutral_~_8wekyb3d8bbwe

Microsoft.XboxGameOverlay_1.34.5003.0_neutral_~_8wekyb3d8bbwe

Microsoft.XboxGamingOverlay_2.21.25005.1000_neutral_~_8wekyb3d8bbwe

Microsoft.XboxIdentityProvider_12.45.6001.0_neutral_~_8wekyb3d8bbwe

Microsoft.XboxSpeechToTextOverlay_1.21.13002.0_neutral_~_8wekyb3d8bbwe

Microsoft.YourPhone_2018.925.223.0_neutral_~_8wekyb3d8bbwe

Microsoft.ZuneMusic_2019.18091.10321.0_neutral_~_8wekyb3d8bbwe

Microsoft.ZuneVideo_2019.18082.10311.0_neutral_~_8wekyb3d8bbwe

Sử dụng lệnh sau để gỡ bỏ ứng dụng

Copy

Dism /Online /Remove-ProvisionedAppxPackage /PackageName:PackageName

Tệp SetupComplete.cmd tham khảo:

Copy

reg add "HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem" /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f

reg add "HKLMSOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem" /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f

Dism /Online /Add-Package /PackagePath:C:Packagesmicrosoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab /Quiet /NoRestart

Start /wait C:Packageswinrar-x64.exe /s

Dism /Online /Remove-ProvisionedAppxPackage /PackageName:Microsoft.WindowsFeedbackHub_2018.822.2.0_neutral_~_8wekyb3d8bbwe

Dism /Online /Remove-ProvisionedAppxPackage /PackageName:Microsoft.Wallet_2.2.18179.0_neutral_~_8wekyb3d8bbwe

Dism /Online /Remove-ProvisionedAppxPackage /PackageName:Microsoft.MicrosoftSolitaireCollection_4.2.8172.0_neutral_~_8wekyb3d8bbwe

del /Q /F C:windowspantherunattend.xml

del /Q /F C:windowspantherunattendgcsetupact.log

rd /s /q C:Packages

rd /s /q C:WindowsSetupScripts

Tạo tệp LayoutModification.xml, tệp này có tác dụng ghim ứng dụng vào Start menu

Copy

<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">

  <LayoutOptions StartTileGroupCellWidth="6" />

  <DefaultLayoutOverride>

    <StartLayoutCollection>

      <defaultlayout:StartLayout GroupCellWidth="6">

        <start:Group Name="Create">

          <start:Tile Size="2x2" Column="0" Row="0" AppUserModelID="microsoft.windowscommunicationsapps_8wekyb3d8bbwe!Microsoft.WindowsLive.Calendar" />

          <start:Tile Size="2x2" Column="2" Row="2" AppUserModelID="Microsoft.MSPaint_8wekyb3d8bbwe!Microsoft.MSPaint" />

          <start:Tile Size="2x2" Column="4" Row="2" AppUserModelID="Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim" />

          <start:Tile Size="4x2" Column="2" Row="0" AppUserModelID="microsoft.windowscommunicationsapps_8wekyb3d8bbwe!Microsoft.WindowsLive.Mail" />

          <start:Tile Size="2x2" Column="0" Row="2" AppUserModelID="Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!Microsoft.MicrosoftOfficeHub" />

        </start:Group>

        <start:Group Name="Play">

          <start:Tile Size="1x1" Column="2" Row="0" AppUserModelID="Microsoft.ZuneVideo_8wekyb3d8bbwe!Microsoft.ZuneVideo" />

          <start:Tile Size="2x2" Column="0" Row="0" AppUserModelID="Microsoft.XboxApp_8wekyb3d8bbwe!Microsoft.XboxApp" />

          <start:Tile Size="1x1" Column="3" Row="0" AppUserModelID="Microsoft.ZuneMusic_8wekyb3d8bbwe!Microsoft.ZuneMusic" />

          <start:Tile Size="1x1" Column="2" Row="1" AppUserModelID="Microsoft.WindowsCalculator_8wekyb3d8bbwe!App" />

          <start:Tile Size="2x2" Column="4" Row="0" AppUserModelID="Microsoft.Windows.Photos_8wekyb3d8bbwe!App" />

          <start:Tile Size="1x1" Column="3" Row="1" AppUserModelID="Microsoft.WindowsMaps_8wekyb3d8bbwe!App" />

        </start:Group>

        <start:Group Name="Explore">

          <start:Tile Size="2x2" Column="4" Row="0" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />

          <start:Tile Size="4x2" Column="0" Row="0" AppUserModelID="Microsoft.WindowsStore_8wekyb3d8bbwe!App" />

        </start:Group>

        <start:Group Name="">

          <start:Tile Size="2x2" Column="2" Row="2" AppUserModelID="Microsoft.MSPaint_8wekyb3d8bbwe!Microsoft.MSPaint" />

        </start:Group>

      </defaultlayout:StartLayout>

    </StartLayoutCollection>

  </DefaultLayoutOverride>

</LayoutModificationTemplate>

Tạo tệp trả lời tự động Unattend.xml

Copy

<?xml version="1.0" encoding="utf-8"?>

<unattend xmlns="urn:schemas-microsoft-com:unattend">

  <settings pass="specialize">

    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <OEMInformation>

        <Manufacturer>Hewlett-Packard©</Manufacturer>

        <SupportHours>8:AM-6:PM All Days</SupportHours>

        <SupportPhone>+123 345 678</SupportPhone>

        <SupportURL>http://www8.hp.com/vn/en/contact-hp/support.html</SupportURL>

        <Model>HP ProBook 4430s</Model>

        <Logo>%windir%system32oobeOEMLogo.bmp</Logo>

      </OEMInformation>

    </component>

    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <OEMInformation>

        <Manufacturer>Hewlett-Packard©</Manufacturer>

        <SupportHours>8:AM-6:PM All Days</SupportHours>

        <SupportPhone>+123 345 678</SupportPhone>

        <SupportURL>http://www8.hp.com/vn/en/contact-hp/support.html</SupportURL>

        <Model>HP ProBook 4430s</Model>

        <Logo>%windir%system32oobeOEMLogo.bmp</Logo>

      </OEMInformation>

    </component>

  </settings>

  <settings pass="oobeSystem">

    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <FirstLogonCommands>

        <SynchronousCommand wcm:action="add">

          <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d 0 /f</CommandLine>

          <Order>1</Order>

          <RequiresUserInput>false</RequiresUserInput>

        </SynchronousCommand>

        <SynchronousCommand wcm:action="add">

          <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SystemPaneSuggestionsEnabled" /t REG_DWORD /d 0 /f</CommandLine>

          <Order>2</Order>

          <RequiresUserInput>false</RequiresUserInput>

        </SynchronousCommand>

        <SynchronousCommand wcm:action="add">

          <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SubscribedContent-338388Enabled" /t REG_DWORD /d 0 /f</CommandLine>

          <Order>3</Order>

          <RequiresUserInput>false</RequiresUserInput>

        </SynchronousCommand>

        <SynchronousCommand wcm:action="add">

          <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SubscribedContent-338393Enabled" /t REG_DWORD /d 0 /f</CommandLine>

          <Order>4</Order>

          <RequiresUserInput>false</RequiresUserInput>

        </SynchronousCommand>

        <SynchronousCommand wcm:action="add">

          <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced" /v "ShowSyncProviderNotifications" /t REG_DWORD /d 0 /f</CommandLine>

          <Order>5</Order>

          <RequiresUserInput>false</RequiresUserInput>

        </SynchronousCommand>

        <SynchronousCommand wcm:action="add">

          <CommandLine>reg add "HKCUSoftwarePoliciesMicrosoftWindowsExplorer" /v "HideRecentlyAddedApps" /t REG_DWORD /d 1 /f</CommandLine>

          <Order>6</Order>

          <RequiresUserInput>false</RequiresUserInput>

        </SynchronousCommand>

      </FirstLogonCommands>

      <Themes>

        <DesktopBackground>C:WindowsSystem32oobeOEMWallapaper.png</DesktopBackground>

        <ThemeName>OEM Theme</ThemeName>

      </Themes>

      <TaskbarLinks>

        <Link0>%allusersprofile%MicrosoftWindowsStart MenuProgramsAccessoriesSnipping Tool.lnk</Link0>

        <Link1>%userprofile%AppDataRoamingMicrosoftWindowsStart MenuProgramsSystem ToolsControl Panel.lnk</Link1>

      </TaskbarLinks>

    </component>

    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <FirstLogonCommands>

      <SynchronousCommand wcm:action="add">

        <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d 0 /f</CommandLine>

        <Order>1</Order>

        <RequiresUserInput>false</RequiresUserInput>

      </SynchronousCommand>

      <SynchronousCommand wcm:action="add">

        <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SystemPaneSuggestionsEnabled" /t REG_DWORD /d 0 /f</CommandLine>

        <Order>2</Order>

        <RequiresUserInput>false</RequiresUserInput>

      </SynchronousCommand>

      <SynchronousCommand wcm:action="add">

        <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SubscribedContent-338388Enabled" /t REG_DWORD /d 0 /f</CommandLine>

        <Order>3</Order>

        <RequiresUserInput>false</RequiresUserInput>

      </SynchronousCommand>

      <SynchronousCommand wcm:action="add">

        <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionContentDeliveryManager" /v "SubscribedContent-338393Enabled" /t REG_DWORD /d 0 /f</CommandLine>

        <Order>4</Order>

        <RequiresUserInput>false</RequiresUserInput>

      </SynchronousCommand>

      <SynchronousCommand wcm:action="add">

        <CommandLine>reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced" /v "ShowSyncProviderNotifications" /t REG_DWORD /d 0 /f</CommandLine>

        <Order>5</Order>

        <RequiresUserInput>false</RequiresUserInput>

      </SynchronousCommand>

      <SynchronousCommand wcm:action="add">

        <CommandLine>reg add "HKCUSoftwarePoliciesMicrosoftWindowsExplorer" /v "HideRecentlyAddedApps" /t REG_DWORD /d 1 /f</CommandLine>

        <Order>6</Order>

        <RequiresUserInput>false</RequiresUserInput>

      </SynchronousCommand>

      </FirstLogonCommand

      <Themes>

        <DesktopBackground>C:WindowsSystem32oobeOEMWallapaper.png</DesktopBackground>

        <ThemeName>OEM Theme</ThemeName>

      </Themes>

      <TaskbarLinks>

        <Link0>%allusersprofile%MicrosoftWindowsStart MenuProgramsAccessoriesSnipping Tool.lnk</Link0>

        <Link1>%userprofile%AppDataRoamingMicrosoftWindowsStart MenuProgramsSystem ToolsControl Panel.lnk</Link1>

      </TaskbarLinks>

    </component>

  </settings>

</unattend>

View Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Published by
4 years ago