Skip to content

Commit a3d97d7

Browse files
committed
[PE Helper] Add new admin script, fix cmdcons issue
1 parent 35c4b6a commit a3d97d7

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

DISMTools.vbproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,9 @@
12001200
<None Include="Helpers\extps1\PE_Helper\files\scripts\fullcopy.bat">
12011201
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
12021202
</None>
1203+
<None Include="Helpers\extps1\PE_Helper\files\scripts\imagecapture.bat">
1204+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1205+
</None>
12031206
<None Include="Helpers\extps1\PE_Helper\files\scripts\initializenetwork.bat">
12041207
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
12051208
</None>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@echo off
2+
cls
3+
echo Image Capture Utility
4+
echo =========================
5+
echo This utility helps you capture an entire Windows installation to a WIM file. This file can be mounted or applied later.
6+
echo.
7+
echo Note that, if you plan on using the Windows installation to deploy it to a network, this utility may produce a result incompatible with this process.
8+
echo.
9+
echo You must have 2 volumes: the volume you want to capture, and the volume on which you want to store the WIM file. You should know the letters assigned to the volumes.
10+
echo.
11+
echo Showing drive letter assignments...
12+
set scriptpath=%TEMP%\%RANDOM%.txt
13+
set configlistpath=%TEMP%\configlist.ini
14+
15+
echo lis vol > %scriptpath%
16+
echo exi >> %scriptpath%
17+
18+
diskpart /s %scriptpath%
19+
20+
set /p sourcedrive=Please enter the letter of the volume to capture:
21+
if not defined sourcedrive (
22+
echo The letter of the volume to capture must be specified.
23+
exit /b 1
24+
)
25+
set /p destdrive=Please enter the letter of the volume the file will be stored on:
26+
if not defined destdrive (
27+
echo The letter of the volume where the image will be stored must be specified.
28+
exit /b 1
29+
)
30+
echo.
31+
set /p destfile=Enter a file name for the target WIM file. Press ENTER without specifying anything to continue with a random name:
32+
if not defined destfile (
33+
set destfile=install_%RANDOM%.wim
34+
)
35+
36+
set /p imagename=Provide a custom name (without quotes) for the resulting Windows image (e.g., "My Amazing Windows installation"):
37+
if not defined imagename (
38+
set imagename=Windows
39+
)
40+
41+
echo Capturing Windows installation to the target WIM file. This can take a long time, depending on the computer's speed.
42+
call :create_config_list %sourcedrive%
43+
set dismstart=%date% %time%
44+
dism /capture-image /imagefile=%destdrive%:\%destfile% /capturedir=%sourcedrive%:\ /scratchdir=%destdrive%:\ /name="%imagename%" /configfile="%configlistpath%" /compress=max /checkintegrity /bootable /verify
45+
if %ERRORLEVEL% equ 0 (
46+
set succeeded=true
47+
) else (
48+
set succeeded=false
49+
)
50+
set dismend=%date% %time%
51+
echo.
52+
echo Capture Run RESULTS:
53+
echo ======================================================
54+
if "%succeeded%" equ "true" (
55+
echo STATUS : The run succeeded
56+
) else (
57+
echo STATUS : The run failed
58+
)
59+
echo DISM Start Time: %dismstart%
60+
echo DISM End Time : %dismend%
61+
echo.
62+
if "%succeeded%" equ "true" (
63+
echo The file has been saved to "%destdrive%:\%destfile%".
64+
)
65+
echo ======================================================
66+
exit /b
67+
68+
:create_config_list
69+
echo Setting up file/folder exclusions for source volume...
70+
REM create the config list file. It will call echo lots of times
71+
echo. > %configlistpath%
72+
echo [ExclusionList] >> %configlistpath%
73+
echo \$ntfs.log >> %configlistpath%
74+
echo \hiberfil.sys >> %configlistpath%
75+
echo \pagefile.sys >> %configlistpath%
76+
echo \swapfile.sys >> %configlistpath%
77+
echo \System Volume Information >> %configlistpath%
78+
echo \RECYCLER >> %configlistpath%
79+
echo \Windows\CSC >> %configlistpath%
80+
for /d %%f in (%~1:\Users\*) do (
81+
if exist "%%f\OneDrive" ( echo %%f\OneDrive >> %configlistpath% )
82+
if exist "%%f\SkyDrive" ( echo %%f\SkyDrive >> %configlistpath% )
83+
)
84+
echo. >> %configlistpath%
85+
echo [CompressionExclusionList] >> %configlistpath%
86+
echo *.mp3 >> %configlistpath%
87+
echo *.zip >> %configlistpath%
88+
echo *.cab >> %configlistpath%
89+
echo \WINDOWS\inf\*.pnf >> %configlistpath%

Helpers/extps1/PE_Helper/files/startup/StartInstall.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ $setupScript[5] = "set debug=0"
44
Set-Content -Path "$env:SYSTEMDRIVE\Windows\system32\startnet.cmd" -Value $setupScript -Force
55
Clear-Host
66
Set-Location "$env:SYSTEMDRIVE\"
7+
Remove-Item -Path "$env:SYSTEMDRIVE\cmdcons" -Force | Out-Null
78
iex "$env:SYSTEMDRIVE\Windows\system32\startnet.cmd"

0 commit comments

Comments
 (0)