0

I am trying to write a .bat script that will:

  1. create a WinPE image;
  2. mount the image;
  3. allow me to make changes to the image;
  4. commit the changes; and
  5. 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?

Andrew
  • 14,325
  • 4
  • 43
  • 64
Bbbh
  • 321
  • 7
  • 20
  • 1. Why that `start cmd /C copype ...`? Why don't you use just `copype ...`? 2. This line is wrong: `) else if %proj_arch% EQU 86 (`, missing a parenthesis: should be `) else ( if %proj_arch% EQU 86 (` and this logic construct to be finalized... – JosefZ Jan 10 '15 at 12:35
  • `copype` will close the script. so if i run it in its own window it will close the new window and the script will continue. i got the `if` logic from C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat and in there it works – Bbbh Jan 10 '15 at 12:49
  • But with `start "" cmd /C copype ...` you should wait until `copype` ends... If `copype` is a batch file, try `call copype ...` – JosefZ Jan 10 '15 at 12:57
  • 1
    i found `start /wait cmd /k ... ` did the trick. i found out batch will run everything at once and not wait for the last line to finish i didn't know about call either which is nice – Bbbh Jan 10 '15 at 15:05

0 Answers0