-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-wim.bat
61 lines (53 loc) · 1.76 KB
/
install-wim.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@echo off
setlocal EnableDelayedExpansion
DISM > nul 2>&1 || echo error: administrator privileges required && pause && exit /b 1
pushd "%~dp0"
set "install_wim="
if exist "sources\install.wim" (
set "install_wim=sources\install.wim"
) else (
if exist "sources\install.esd" (
set "install_wim=sources\install.esd"
) else (
echo error: directory does not appear to be a windows image
echo info: press any key to continue
pause > nul 2>&1
exit /b 1
)
)
:select_drive
set /p install_dir="info: enter the drive letter you created to install windows on: "
set "err=0"
if defined install_dir (
if exist "!install_dir!:" (
if exist "autounattend.xml" (
DISM /Apply-Image /ImageFile:"!install_wim!" /Apply-Unattend:"autounattend.xml" /Index:1 /ApplyDir:"!install_dir!:"
if not !errorlevel! == 0 (
set "err=1"
) else (
if exist "!install_dir!:\Windows\System32\Sysprep" (
copy /y "autounattend.xml" "!install_dir!:\Windows\System32\Sysprep" > nul 2>&1
) else (
echo error: sysprep folder does not exist
set "err=1"
)
)
) else (
DISM /Apply-Image /ImageFile:"!install_wim!" /Index:1 /ApplyDir:"!install_dir!:"
if not !errorlevel! == 0 (
set "err=1"
)
)
if !err! == 0 (
bcdboot "!install_dir!:\Windows" > nul 2>&1
echo info: restart pc
) else (
echo error: dism apply-image unsuccessful
)
echo info: press any key to continue
pause > nul 2>&1
exit /b !err!
)
)
echo error: invalid input
goto :select_drive