我想在部署工具命令提示符(Windows AIK 的一部分)内运行批处理脚本来创建 WinPE iso。我完成了准备媒体的步骤并创建了一个脚本来导航到正确的目录,然后运行 oscdimg.exe 工具。
问题在于它在正常命令提示符下运行,而不是在部署工具命令提示符下运行。是否可以编写一个在部署工具命令提示符而不是常规命令提示符中运行的脚本?
我的基本脚本:
@echo off
@echo Running OSCDIMG to create a WinPE amd64 iso in f:\OtherItems\view_stores\WinPE7\winpe.iso
f:
cd \OtherItems\view_stores\WinPE7
oscdimg.exe -n -bf:\OtherItems\view_stores\WinPE7\etfsboot.com f:\OtherItems\view_stores\WinPE7\ISO f:\OtherItems\view_stores\WinPE7\winpe.iso
@echo **********************************************************************
@echo Done.
@echo
pause
如果您查看“部署工具命令提示符”的属性,目标是:
C:\Windows\System32\cmd.exe /k "C:\Program Files\Windows AIK\Tools\PETools\pesetenv.cmd"
所以它不是一个单独的程序,而是在常规cmd提示符下批量运行。
您可以获取“pesetenv.cmd”的内容并将其用作批处理的前缀:
现在部署工具命令应该可以按预期工作。
编辑: 刮掉上面的内容,我不知道为什么我认为那是在做某事。添加 oscdimg.exe 和 imagex.exe 的完整路径对我来说很有效。
C:\Program Files\Windows AIK\Tools\x86\oscdimg.exe -n -bf:\OtherItems\view_stores\WinPE7\etfsboot.com f:\OtherItems\view_stores\WinPE7\ISO f:\OtherItems\view_stores\WinPE7\winpe.iso
我知道这是一篇旧帖子,但是我最近发现它正在寻找类似的解决方案。
我最终使用 PowerShell 脚本来创建扩展批处理文件。您可能需要根据您的情况/版本稍微修改它。
param (
$Path = "$PSScriptRoot\WinPE_amd64_PS",
$IsoDestinationPath = "$PSScriptRoot\WinPE_amd64_modified.iso"
)
$devToolsPath = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools"
$inputFile = "$devToolsPath\DandISetEnv.bat"
$outputFile = "$devToolsPath\DandISetEnvCustom.bat"
if (Test-Path $outputFile) {
$null = Remove-Item $outputFile
}
$null = Copy-Item -Force -Path $inputFile -Destination $outputFile
$null = Add-Content -Path $outputFile -Value ""
$null = Add-Content -Path $outputFile -Value ""
$null = Add-Content -Path $outputFile -Value "rem Custom Commands"
$null = Add-Content -Path $outputFile -Value "Dism /Mount-Image /ImageFile:`"$Path\media\sources\boot.wim`" /index:1 /MountDir:`"$Path\mount`""
$null = Add-Content -Path $outputFile -Value "Dism /Unmount-Image /MountDir:`"$Path\mount`" /commit"
$null = Add-Content -Path $outputFile -Value "MakeWinPEMedia /ISO `"$Path`" `"$IsoDestinationPath`""
$null = Add-Content -Path $outputFile -Value ""
Write-Host "Running script `"$outputFile`"."
cmd.exe /c $outputFile