I am trying to write a .bat script that will:
- create a WinPE image;
- mount the image;
- allow me to make changes to the image;
- commit the changes; and
- create an .iso image.
My script is this:
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
My issue is when DISM /mount-wim
fails in this batch (even if I change %proj_name%
to test
), but it works normally in the same command prompt after my script has run. For example:
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
fails with wim not found
, but:
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"
is successful.
How can I get DISM to work in my build script?