68 lines
1.4 KiB
Batchfile
68 lines
1.4 KiB
Batchfile
@echo off
|
|
set COPY_IMAGE=null
|
|
set ISODRIVE=Y:
|
|
|
|
IF %1.==. GOTO USAGE
|
|
IF %2.==. GOTO USAGE
|
|
IF "%~3" NEQ "" set COPY_IMAGE=%3
|
|
|
|
echo.
|
|
echo ====================
|
|
echo Create USB Stick ...
|
|
echo ====================
|
|
|
|
rem get fullpath of isofile ...
|
|
set USBDRIVE=%1
|
|
set ISOFILE=%~f2
|
|
|
|
if NOT EXIST %ISOFILE% (
|
|
echo ERROR: file %ISOFILE% not found!
|
|
exit /b
|
|
)
|
|
|
|
if /I %USBDRIVE% == C: (
|
|
echo ERROR: cannot use drive %USBDRIVE% !
|
|
exit /b
|
|
)
|
|
|
|
if NOT EXIST %USBDRIVE% (
|
|
echo ERROR: drive %USBDRIVE% not found!
|
|
exit /b
|
|
)
|
|
|
|
rem =====
|
|
rem MAIN
|
|
rem =====
|
|
|
|
echo using drive %USBDRIVE% ...
|
|
echo using image %ISOFILE% ...
|
|
|
|
echo mounting disk image (iso) with powershell ...
|
|
powershell "$diskImg = Mount-DiskImage -ImagePath %ISOFILE% -NoDriveLetter; $volInfo = $diskImg | Get-Volume; mountvol %ISODRIVE% $volInfo.UniqueId"
|
|
|
|
if /I %COPY_IMAGE% == /W (
|
|
echo copying ALL files including wim from ISO to targetpath %USBDRIVE% ...
|
|
robocopy %ISODRIVE%\ %USBDRIVE% /MIR /256 /NFL /NDL /R:10
|
|
) else (
|
|
echo copying files from ISO WITHOUT wim to targetpath %USBDRIVE% ...
|
|
robocopy %ISODRIVE%\ %USBDRIVE% /MIR /256 /NFL /NDL /R:10 /XF *.wim
|
|
)
|
|
|
|
echo unmounting disk image (iso) ...
|
|
powershell Dismount-Diskimage -ImagePath %ISOFILE%
|
|
|
|
echo READY.
|
|
echo.
|
|
|
|
rem =====
|
|
rem END
|
|
rem =====
|
|
GOTO END
|
|
|
|
:USAGE
|
|
echo "usage: %0 <USBDRIVE> <ISOFILE> [/w]"
|
|
echo /w = copy windows images to target
|
|
echo.
|
|
:END
|
|
|