0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Windows PE をカスタマイズしてisoファイルに書き出すバッチファイル

0
Posted at

はじめに

Windows PE のメディアを作成するときに、一緒にアプリケーションを含める場合は、一度マウントしてコミットする必要があるので、その操作を自動で行えるように、バッチファイルのコードを作成しました。

含めるアプリケーションは自由に入れれるので、Customize のところで、アプリケーションのコピーなどのコマンドを記述しておくと、自動でWindows PEisoを作成できます。

Code

@echo off
setlocal

net session >nul 2>&1
if errorlevel 1 (
    powerShell -Command "Start-Process -Verb RunAs -FilePath '%0'"
    exit /b
)

set ADK_PATH=C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\
set ADK_DEV_TOOLS_DIR=%ADK_PATH%Deployment Tools\
set ADK_WIN_PE_DIR=%ADK_PATH%Windows Preinstallation Environment\
set ADK_DEV_TOOLS_ENV_PATH=%ADK_DEV_TOOLS_DIR%DandISetEnv.bat

set PE_OUT_DIR=%~dp0.out\
set PE_TMP_DIR=%PE_OUT_DIR%win-pe\

: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install
: 
: "Download the Windows ADK" for Windows 11, version 22H2 (updated September 2023)
: "Download the Windows PE add-on" for the Windows ADK for Windows 11, version 22H2 (updated September 2023)
: 
: "Download the Windows ADK" Enable Developer Tools

if not exist "%ADK_DEV_TOOLS_DIR%" (
    echo Developer Tools is not installed.
    goto :EXIT
)
if not exist "%ADK_WIN_PE_DIR%" (
    echo Windows PE Addon is not installed.
    goto :EXIT
)

echo Initialize...

Dism /Unmount-Image /MountDir:%PE_TMP_DIR%mount /Discard >nul 2>&1
if exist "%PE_OUT_DIR%" ( rmdir /s /q "%PE_OUT_DIR%" )
mkdir "%PE_OUT_DIR%"

call "%ADK_DEV_TOOLS_ENV_PATH%"
call copype amd64 "%PE_TMP_DIR%" 
Dism /mount-image /ImageFile:%PE_TMP_DIR%media\sources\boot.wim /Index:1 /MountDir:%PE_TMP_DIR%mount

echo ------------------------ Customize ------------------------

: ここにアプリケーションの移動やらを記述
: .out\win-pe\mountの中に入れることで、PE起動時に含まれるようにすることができる

echo -----------------------------------------------------------

Dism /Unmount-Image /MountDir:%PE_TMP_DIR%mount /Commit
call MakeWinPEMedia /ISO %PE_TMP_DIR% %PE_OUT_DIR%windows_pe_amd64.iso

endlocal
:EXIT
pause

Reference

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?