Skip to content

Instantly share code, notes, and snippets.

@il-katta
Created November 8, 2016 11:38
Show Gist options
  • Save il-katta/54d48c00001fb8589ae62c2c2a4ed9ed to your computer and use it in GitHub Desktop.
Save il-katta/54d48c00001fb8589ae62c2c2a4ed9ed to your computer and use it in GitHub Desktop.
@echo off
rem maybe this software is needed: https://www.microsoft.com/en-us/download/details.aspx?id=48595
rem set WindowsISO=%cd%\%1
set WindowsISO="%cd%\Windows10.iso"
shift
ECHO create partitions
DiskPart /s diskpart_create_single.txt
rem se il file install.wim non è già stato estratto
IF NOT EXIST "%CD%\install.wim" (
ECHO mounting windows 10 iso file
PowerShell -Command Mount-DiskImage -ImagePath "%WindowsISO%"
ECHO getting drive letter of iso
FOR /F "skip=3" %%I IN ('powershell.exe "Get-DiskImage """%WindowsISO%""" | Get-Volume | Select-Object {$_.DriveLetter}"') DO (
set IsoDriveLetter=%%I
)
ECHO exporting image
Dism /Quiet /Capture-Image /ImageFile:"%CD%\install.wim" /CaptureDir:.\temp /Name:container /Compress:max /CheckIntegrity
Dism /Export-Image /SourceImageFile:"%IsoDriveLetter%\sources\install.esd" /SourceIndex:1 /DestinationImageFile:"%CD%\install.wim" /compress:recovery /CheckIntegrity
Dism /Quiet /Delete-Image /ImageFile:"%CD%\install.wim" /Index:1 /CheckIntegrity
ECHO unmounting iso
PowerShell -Command Dismount-DiskImage -ImagePath "%WindowsISO%"
)
ECHO coping files to usb device
Dism /Apply-Image /ImageFile:"%CD%\install.wim" /Index:1 /ApplyDir:W:\
rem Dism /image:W:\ /Set-TargetPath:X:\
ECHO creating boot option
bcdboot W:\Windows /s W: /f ALL /l en-US
rem reagentc /setosimage /path R: /target W:\Windows /index 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment