如何从批处理文件运行 WinPE 的 copype.cmd

如何从批处理文件运行 WinPE 的 copype.cmd

我正在编写一个为您设置 WinPE 驱动器的工具,并且我一直在从管理员批处理文件中调用 DISM 命令。但是,我无法弄清楚如何运行 copype 命令来初始设置驱动器。

"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\copype.cmd"是 copype 工具所在的位置,但是当使用 dism 调用它时,使用此命令:Dism "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\copype.cmd" amd64 C:\WinPE_amd64它响应Dism doesn't recognise the command-line option "copype.cmd"如果我尝试直接从命令提示符运行该文件,它会说找不到 amd64 基础结构。我可以让它启动的唯一方法是运行管理员部署和映像工具环境并运行 copype 命令。一定有办法做到这一点,但我不知道怎么做。

答案1

事实证明,Windows ADK Copype 自 Windows 8 以来就有点问题。它缺少一些变量。如果您将其放入批处理文件中,则可以使用call :copype它来调用命令:

:copype
setlocal

set TEMPL=media
set FWFILES=fwfiles

rem
rem Input validation
rem
if /i "%1"=="/?" goto usage
if /i "%1"=="" goto usage
if /i "%~2"=="" goto usage
if /i not "%3"=="" goto usage

rem
rem Set environment variables for use in the script
rem
set WINPE_ARCH=%1
set SOURCE=C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\%WINPE_ARCH%
set FWFILESROOT=C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\%WINPE_ARCH%\Oscdimg
set DEST=%~2
set WIMSOURCEPATH=%SOURCE%\en-us\winpe.wim

rem
rem Validate input architecture
rem
rem If the source directory as per input architecture does not exist,
rem it means the architecture is not present
rem
if not exist "%SOURCE%" (
  echo ERROR: The following processor architecture was not found: %WINPE_ARCH%.
  exit /b 1
)

rem
rem Validate the boot app directory location
rem
rem If the input architecture is validated, this directory must exist
rem This check is only to be extra careful
rem
if not exist "%FWFILESROOT%" (
  echo ERROR: The following path for firmware files was not found: "%FWFILESROOT%".
  exit /b 1
)

rem
rem Make sure the appropriate winpe.wim is present
rem
if not exist "%WIMSOURCEPATH%" (
  echo ERROR: WinPE WIM file does not exist: "%WIMSOURCEPATH%".
  exit /b 1
)

rem
rem Make sure the destination directory does not exist
rem
if exist "%DEST%" (
  echo ERROR: Destination directory exists: %2.
  exit /b 1
)

mkdir "%DEST%"
if errorlevel 1 (
  echo ERROR: Unable to create destination: %2.
  exit /b 1
)

echo.
echo ===================================================
echo Creating Windows PE customization working directory
echo.
echo     %DEST%
echo ===================================================
echo.

mkdir "%DEST%\%TEMPL%"
if errorlevel 1 goto :FAIL
mkdir "%DEST%\mount"
if errorlevel 1 goto :FAIL
mkdir "%DEST%\%FWFILES%"
if errorlevel 1 goto :FAIL

rem
rem Copy the boot files and WinPE WIM to the destination location
rem
xcopy /cherky "%SOURCE%\Media" "%DEST%\%TEMPL%\"
if errorlevel 1 goto :FAIL
mkdir "%DEST%\%TEMPL%\sources"
if errorlevel 1 goto :FAIL
copy "%WIMSOURCEPATH%" "%DEST%\%TEMPL%\sources\boot.wim"
if errorlevel 1 goto :FAIL

rem
rem Copy the boot apps to enable ISO boot
rem
rem  UEFI boot uses efisys.bin
rem  BIOS boot uses etfsboot.com
rem
copy "%FWFILESROOT%\efisys.bin" "%DEST%\%FWFILES%"
if errorlevel 1 goto :FAIL
if exist "%FWFILESROOT%\etfsboot.com" (
  copy "%FWFILESROOT%\etfsboot.com" "%DEST%\%FWFILES%"
  if errorlevel 1 goto :FAIL
)

endlocal
echo.
echo Success
echo.

cd /d "%~2"

goto :EOF

:usage
echo Creates working directories for WinPE image customization and media creation.
echo.
echo copype { amd64 ^| x86 ^| arm } ^<workingDirectory^>
echo.
echo  amd64             Copies amd64 boot files and WIM to ^<workingDirectory^>\media.
echo  x86               Copies x86 boot files and WIM to ^<workingDirectory^>\media.
echo  arm               Copies arm boot files and WIM to ^<workingDirectory^>\media.
echo                    Note: ARM content may not be present in this ADK.
echo  workingDirectory  Creates the working directory at the specified location.
echo.
echo Example: copype amd64 C:\WinPE_amd64
goto :EOF

:FAIL
echo ERROR: Failed to create working directory.
set EROP=YEs
exit /b 1
Rem CopyPE created by Microsoft and Edited by Lucas Elliott and wjsorensen on technet
::------------------------ END --------------------------

对于使用 Windows 8 的任何人,您可以在此处查看他们的解决方案:https://social.technet.microsoft.com/Forums/ie/en-US/1155d38c-e7fd-4b4f-a31c-26875d4f47a7/windows-pe-error-using-windows-8-adk?forum=w8itproinstall

答案2

嗯,我来这里是为了寻找有关 copype 的信息,并点击链接进入了 technet 论坛。几天前有一篇新帖子 - 我强烈建议您阅读它。简而言之,copype 根本没有问题:它只是应该从 ADK 环境(通过单击“开始”->“所有程序”->“Windows 工具包”->“Windows ADK”中的相应链接调用的 cmd 提示符)运行。(哦,这是 Win 7 上的路径:我在 Windows 7 上安装了 Windows 8 ADK(版本 6.3.9600.17029);在 Win 8 中,可能在 Win 10 中,由于“开始”菜单的布局不同,路径会有所不同。)

相关内容