我正在尝试编写一个 .bat 脚本,它将:
- 创建 WinPE 映像;
- 挂载镜像;
- 请允许我对图像进行更改;
- 提交更改;和
- 创建一个 .iso 映像。
我的脚本是这样的:
set /p proj_name=What is project name:
set /p proj_arch=What is the architecture (86 or 64):
REM Build Image
IF %proj_arch% EQU 64 (
echo Building x64 in C:\winPE\builds\%proj_name%
start cmd /C copype amd64 C:\winPE\builds\%proj_name%
) else if %proj_arch% EQU 86 (
echo Building x86 in C:\winPE\builds\%proj_name%
start cmd /C copype x86 C:\winPE\builds\%proj_name%
)
REM Mount image
echo mounted directoy at c:\winpe\mount
DISM /Mount-Wim /WimFile:"C:\winPE\builds\%proj_name%\media\sources\boot.wim" /index:1 /MountDir:"C:\winPE\mount"
Echo =============================================
echo To unmount and create ISO:
pause
Dism /Unmount-Wim /MountDir:"C:\WinPE\mount" /commit
Dism /Cleanup-Mountpoints
echo Creating iso in c:\winpe\
MakeWinPEMedia /ISO C:\winPE\builds\%proj_name% C:\WinPE_amd64\%proj_name%.iso
pause
我的问题是当DISM /mount-wim
这批失败时(即使我更改%proj_name%
为test
),但在我的脚本运行后它在同一个命令提示符下正常工作。例如:
测试.bat
start cmd /C copype amd64 C:\winPE\builds\test
DISM /Mount-Wim /WimFile:"C:\winPE\builds\test\media\sources\boot.wim" /index:1 /MountDir:"C:\winPE\mount"
c:\winpe> cmd test.bat
失败wim not found
,但是:
test2.bat
start cmd /C copype amd64 C:\winPE\builds\test
c:\winpe> cmd test2.bat
c:\winpe> DISM /Mount-Wim /WimFile:"C:\winPE\builds\test\media\sources\boot.wim" /index:1 /MountDir:"C:\winPE\mount"
是成功的。
如何让 DISM 在我的构建脚本中工作?