0

I'm trying to automate some DISM processes.

After booting winpe from USB, some times the drive letters changes, so I need to build a batch file that displays the different volumes so the user can select the drive letter for the DISM capture-image command.

I have no experience in .bat programming, so this is what I have and does not work, but I'm posting the code so you can give me better advice.

name of the file: Golden.bat

    diskpart     *After this command the program breaks*
    list vol
    exit

    @echo off     *This part also does not work gives error 3*
    set /p Drive=Escribe la letra del Drive destino para la Imagen Golden:
    if "%Drive%"=="" goto :FIN

    Dism /Capture-Image /ImageFile:"%Drive%"":\Golden\Golden.wim" /CaptureDir:C:\ /Name:Golden
    :FIN

   @echo on

   echo Fin del Proceso de Captura de Imagen Golden!
alxlives
  • 5,084
  • 4
  • 28
  • 50
  • 1
    You execute `diskpart` and only when it finishes, the parser tries to execute the next line `list vol` - and fails, because `list` is not a valid `cmd` command. See [here](https://ss64.com/nt/diskpart.html) for how to feed `diskpart` with commands. – Stephan Oct 10 '19 at 16:24
  • Would you mind using punctuation? it would make your description much easier to read... – aschipfl Oct 10 '19 at 18:05

1 Answers1

0

Hi guys thank you for your replies, I came up with a solution, is really basic, hope you could help me improve de code. I have Created 3 files Golden.bat,listvol.txt,creaimagen.bat and here is the code


Golden.bat

@echo off
diskpart /s listvol.txt
call creaimagen.bat

listvol.txt

select disk 0 
list vol
exit

creaimagen.bat

@echo off
set /p Drive=Escribe la letra del Drive destino para la Imagen Golden:
if "%Drive%"=="" goto :FIN
SET preruta = 
SET ruta = %Drive%%preruta%
@Echo Off
Setlocal
(Set preruta=:\Golden\Golden.wim)
(Set two=%Drive%)
(Set three=%two%%preruta%)
Echo/%%three%%=%three%

dism /Capture-Image /imagefile:%three% /capturedir:C:\ /name:Golden
:FIN
echo Fin del Proceso de Captura de Imagen Golden!
pause