├── 0.1_CreateDefaultAssociations.cmd
├── 0.2_CreateDefaultStartMenuLayout.ps1
├── 1_Preperations.cmd
├── 2_Sysprep.cmd
├── 3_CreateImage.cmd
├── 4_SplitImage.cmd
├── A_StartInstallation.cmd
├── B_FixDefault.cmd
├── LICENSE
├── README.md
├── ScriptFiles
├── CreatePartitions.dps
├── DefaultAssociations.xml
├── Disable 3D Objects folder.reg
├── Disable AeroShake.reg
├── Disable Cortana and Start Menu Web Search.reg
├── Disable News & Meet.reg
├── EmptyDefault.cmd
├── LayoutModification.xml
├── Set Default Apps.reg
└── unattend.xml
└── X_EmergencyFixDefault.cmd
/0.1_CreateDefaultAssociations.cmd:
--------------------------------------------------------------------------------
1 | dism /Online /Export-DefaultAppAssociations:C:\DefaultAssociations.xml
2 | pause
3 | exit
--------------------------------------------------------------------------------
/0.2_CreateDefaultStartMenuLayout.ps1:
--------------------------------------------------------------------------------
1 | Export-StartLayout -Path C:\LayoutModification.xml
--------------------------------------------------------------------------------
/1_Preperations.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd %~dp0
3 |
4 | robocopy "ScriptFiles" "%localappdata%\Microsoft\Windows\Shell" "LayoutModification.xml"
5 | robocopy "ScriptFiles" "C:\Install" "unattend.xml"
6 | robocopy "ScriptFiles" "C:\ProgramData\Install" "DefaultAssociations.xml"
7 |
8 | reg import "ScriptFiles\Disable 3D Objects folder.reg"
9 | reg import "ScriptFiles\Disable AeroShake.reg"
10 | reg import "ScriptFiles\Disable Cortana and Start Menu Web Search.reg"
11 | reg import "ScriptFiles\Disable News & Meet.reg"
12 | reg import "ScriptFiles\Set Default Apps.reg"
13 |
14 | popd
15 | pause
16 | exit
17 |
--------------------------------------------------------------------------------
/2_Sysprep.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | start C:\Windows\System32\Sysprep\sysprep.exe /oobe /generalize /shutdown /unattend:C:\Install\unattend.xml
3 | exit
4 |
--------------------------------------------------------------------------------
/3_CreateImage.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | start /b /w %~dp0\ScriptFiles\EmptyDefault.cmd
3 | rd /q /s C:\Install
4 | mkdir D:\Scratch
5 | dism /Capture-Image /ImageFile:D:\install.wim /CaptureDir:C:\ /ScratchDir:D:\Scratch /name:"CustomWin10Pro" /compress:Max /CheckIntegrity /verify /bootable
6 |
--------------------------------------------------------------------------------
/4_SplitImage.cmd:
--------------------------------------------------------------------------------
1 | dism /Split-Image /ImageFile:D:\install.wim /SWMFile:D:\install.swm /FileSize:4000
2 | pause
3 | exit
4 |
--------------------------------------------------------------------------------
/A_StartInstallation.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | diskpart /s %~d0\ScriptFiles\CreatePartitions.dps
3 | dism /Apply-Image /ImageFile:%~d0\sources\install.swm /SWMFile:%~d0\sources\install*.swm /Index:1 /ApplyDir:W:\ /CheckIntegrity /Verify
4 | bcdboot W:\Windows /s S:
5 | md R:\Recovery\WindowsRE
6 | copy %~d0\ScriptFiles\winre.wim R:\Recovery\WindowsRE
7 | W:\Windows\System32\ReAgentc.exe /SetReImage /Path R:\Recovery\WindowsRE /Target W:\Windows
8 |
--------------------------------------------------------------------------------
/B_FixDefault.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | rd /s /q "C:\Users\Default\AppData\Local\Microsoft\Windows\WebCache"
3 | echo Done.
4 | pause
5 | exit
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Jan G. (Rsge)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Custom-Windows-Image-Creation-Helper
2 | Tutorial and scripts to help with the preparation and creation of and installation using a custom Windows 10 image.
3 |
4 | Much of the first part is adapted from [this blogpost by James Rankin](https://james-rankin.com/articles/creating-a-custom-default-profile-on-windows-10-v1803/) [[Archived link](https://web.archive.org/web/20210525055756/https://james-rankin.com/articles/creating-a-custom-default-profile-on-windows-10-v1803/)].
5 | The second part is adapted from [this post on the TenForums](https://www.tenforums.com/tutorials/72031-create-windows-10-iso-image-existing-installation.html#Part5) [[Archived link](https://web.archive.org/web/20211201160745/https://www.tenforums.com/tutorials/72031-create-windows-10-iso-image-existing-installation.html#Part5)] from point 5.3) onwards.
6 |
7 | ## What you need
8 | * A PC with a clean installation of windows, with no user set up yet (asking which region you're in).
9 | * A [standard bootable Windows installation USB stick](https://www.microsoft.com/en-us/software-download/windows10) with a copy of all the files from here in a subfolder on it, plugged into the PC.
10 | * An additional copy of the `winre.wim` file found in the default installation or got through [this method](https://docs.microsoft.com/de-de/windows-hardware/manufacture/desktop/deploy-windows-re?view=windows-10) in the `ScriptFiles` folder.
11 |
12 | ## Creation of custom install files
13 | 1. In the region choice screen, press `Ctrl+Shift+F3`.
14 | The PC reboots into Audit Mode and gives you a temporary account to work with.
15 | 2. Close the *System Preparation Tool* window.
16 | 3. Configure windows settings according to your needs and wants.
17 | 4. [Uninstall and disable unwanted UWPs (Windows 10 default Apps)](https://james-rankin.com/articles/how-to-remove-uwp-apps-on-windows-10-v1803/) [[Archived link](https://web.archive.org/web/20211209142423/https://james-rankin.com/articles/how-to-remove-uwp-apps-on-windows-10-v1803/)]
18 | 1. Open PowerShell as Administrator (`Ctrl+Shift`).
19 | 2. Run `Get-AppxProvisionedPackage -online | Out-GridView -PassThru | Remove-AppxProvisionedPackage -online`.
20 | 3. Select all Apps you don't want (Ctrl+Click) and click ok. Wait for it running.
21 | 4. Run `Get-AppxPackage -AllUsers | Out-GridView -PassThru | Remove-AppxPackage`.
22 | 5. Select all Apps you don't want (Ctrl+Click) and click ok. Wait for it running. If there are errors ignore them.
23 | 6. Go the normal program list and uninstall any additional unwanted programs (e.g. OneDrive).
24 | 5. Install programs to provide by default (e.g. Firefox, MS Office, ...).
25 | 6. Configure these programs' settings (e.g. config and install Addons in Firefox) and make them default for their filetypes if wanted.
26 | * If a program you're using saves it's settings in `AppData`, add the corresponding folder/file in the `EmptyDefault.cmd` from `ScriptFiles`.
27 | 7. Run `0.1_CreateDefaultAssociations.cmd`.
28 | 8. Run `0.2_CreateDefaultStartMenuLayout.ps1`.
29 | * If that doesn't work, run `Export-StartLayout -Path C:\LayoutModification.xml` in an elevated PowerShell.
30 | 10. Open `C:\defaultassociations.xml` and edit it according to the wanted default file associations. (An example is provided in `ScriptFiles`.)
31 | 11. Open `C:\LayoutModification.xml` and [add the Taskbar Layout as needed](https://docs.microsoft.com/en-us/windows/configuration/configure-windows-10-taskbar#sample-taskbar-configuration-added-to-start-layout-xml-file) [[Archived link](https://web.archive.org/web/20220121115213/https://docs.microsoft.com/en-us/windows/configuration//configure-windows-10-taskbar#sample-taskbar-configuration-added-to-start-layout-xml-file)].
32 | * An example is provided in `ScriptFiles`.
33 | 13. Cut & paste your modified XMLs from 8. & 9. into the `ScriptFiles` folder, replacing my default ones.
34 | 14. Run `1_Preparations.cmd` elevated.
35 | 15. Run the partition manager.
36 | 16. Shrink your main partition by 15-25 GB.
37 | 17. Create a new partition with this space called `Install`.
38 | 18. Run `2_Sysprep.cmd` elevated and wait for the system to shut down.
39 | 19. Start your system from the USB stick.
40 | 20. In the installation screen, press `Shift+F10` to open the command prompt.
41 | 21. Use `E:` (probably, or `D:` if you don't have an optical drive) to change to your stick and `cd` to the directory the `.cmd` files are located in.
42 | 22. Run `3_CreateImage.cmd` (from the command line). This will take a while (> 20 min probably, so go make yourself a coffee or whatever).
43 | 23. Close command line and installation window and reboot your system normally.
44 | 24. Go through the first user creation process until you reach the desktop.
45 | 25. Open the USB stick and run `4_SplitImage.cmd`. This will again take a short while (> 5 min probably).
46 | 26. Open the `sources` folder on your USB stick and delete `install.wim` from it.
47 | 27. Open the *Install* partition in file explorer.
48 | 28. Copy all `.swm` files (not the `.wim` file) into the sources dir of your stick.
49 | 29. Use the partition manager to delete the Install partition and reclaim it's space for your main partition.
50 | 30. You now have a stick with an installer for a customized Windows.
51 |
52 | ## Creation of custom ISO image
53 | (You can skip this if you are happy with the USB stick.)
54 | 1. Temporarily move the folder containing the scripts from your USB stick to somewhere else (e.g. the Desktop).
55 | 2. Download the [*Windows Assessment and Deployment Kit (ADK)*](https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit).
56 | 3. Install only the *Deployment Tools*. (You don't need anything else.)
57 | 4. Open the (newly installed) *Deployment and Imaging Tools* elevated.
58 | 5. Run command `cd\`.
59 | 6. Run `oscdimg.exe -m -o -u2 -udfver102 -bootdata:2#p0,e,bE:\boot\etfsboot.com#pEF,e,bE:\efi\microsoft\boot\efisys.bin E: C:\CustomWin10.iso`.
60 | Replace `E:` with the drive letter of your USB stick and `C:\CustomWin10.iso` with the path and name of the ISO file you want.
61 | This will again take a short while.
62 | 7. The image was created at the specified path. Renaming the file is possible without any special care.
63 | 8. Move the folder with scripts back onto your USB stick.
64 |
65 | ## Installation with custom install files
66 | Because of the split image and the nature of custom installations, a few things are different from a normal installation.
67 | 1. Plug in your USB stick from above into a new PC.
68 | 2. Boot from the USB stick.
69 | 3. In the installation screen, press `Shift+F10` to open the command prompt.
70 | 4. Use `D:` (probably now) to change to your USB stick and `cd` to the directory the `.cmd` files are located in.
71 | 5. Run `A_StartInstallation.cmd`. This will take a while (> 15 min probably, go get a second refreshment if you like).
72 | 6. Close command line and installation window and reboot your system normally.
73 | 7. Got through the first user creation process until you reach the desktop.
74 | 8. **Important!** Run `B_FixDefault.cmd` elevated.
75 | **If you don't do this step, new logins will take ages and won't work correctly the first few times.**
76 | If you forget this step, you can run `X_EmergencyFixDefault.cmd` elevated on any user to fix it for future users.
77 |
--------------------------------------------------------------------------------
/ScriptFiles/CreatePartitions.dps:
--------------------------------------------------------------------------------
1 | rem == CreatePartitions-UEFI.txt ==
2 | rem == These commands are used with DiskPart to
3 | rem create four partitions
4 | rem for a UEFI/GPT-based PC.
5 | rem Adjust the partition sizes to fill the drive
6 | rem as necessary. ==
7 | select disk 0
8 | clean
9 | convert gpt
10 | rem == 1. System partition =========================
11 | create partition efi size=100
12 | rem ** NOTE: For Advanced Format 4Kn drives,
13 | rem change this value to size = 260 **
14 | format quick fs=fat32 label="System"
15 | assign letter="S"
16 | rem == 2. Microsoft Reserved (MSR) partition =======
17 | create partition msr size=16
18 | rem == 3. Windows partition ========================
19 | rem == a. Create the Windows partition ==========
20 | create partition primary
21 | rem == b. Create space for the recovery tools ===
22 | rem ** Update this size to match the size of
23 | rem the recovery tools (winre.wim)
24 | rem plus some free space.
25 | shrink minimum=500
26 | rem == c. Prepare the Windows partition =========
27 | format quick fs=ntfs label="Windows"
28 | assign letter="W"
29 | rem === 4. Recovery partition ======================
30 | create partition primary
31 | format quick fs=ntfs label="Recovery"
32 | assign letter="R"
33 | set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
34 | gpt attributes=0x8000000000000001
35 | list volume
36 | exit
--------------------------------------------------------------------------------
/ScriptFiles/DefaultAssociations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ScriptFiles/Disable 3D Objects folder.reg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rsge/Custom-Windows-Image-Creation-Helper/295c2da5030c51b3774d333a08a57d88d72d4f0b/ScriptFiles/Disable 3D Objects folder.reg
--------------------------------------------------------------------------------
/ScriptFiles/Disable AeroShake.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer]
4 | "NoWindowMinimizingShortcuts"=dword:00000001
5 |
6 |
--------------------------------------------------------------------------------
/ScriptFiles/Disable Cortana and Start Menu Web Search.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer]
4 | "DisableSearchBoxSuggestions"=dword:00000001
5 |
6 | [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search]
7 | "AllowCortana"=dword:00000000
--------------------------------------------------------------------------------
/ScriptFiles/Disable News & Meet.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds]
4 | "ShellFeedsTaskbarViewMode"=dword:00000002
5 | "ShellFeedsTaskbarOpenOnHover"=dword:00000000
6 |
7 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
8 | "HideSCAMeetNow"=dword:00000001
9 |
--------------------------------------------------------------------------------
/ScriptFiles/EmptyDefault.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd C:\Users\Default\AppData && (
3 | rem takeown /f local\Microsoft\WindowsApps /r /a /d J
4 | rem icacls local\Microsoft\WindowsApps /grant Administrators:F /T /C /L
5 | rd /q /s LocalLow
6 | mkdir LocalLow
7 | popd
8 | )
9 | pushd "C:\Users\Default\AppData\Local\Microsoft\Windows" && (
10 | for /f "tokens=*" %%a in ('dir /A:D /b') do (
11 | if not "%%a" == "Shell" if not "%%a" == "WinX" (
12 | rd /s /q "%%a"
13 | )
14 | )
15 | del /f /q *.* 2> nul
16 | del /f /q /ah *.* 2> nul
17 | popd
18 | )
19 | pushd "C:\Users\Default\AppData\Local\Microsoft\Office" && (
20 | for /f "tokens=*" %%b in ('dir /A:D /b') do (
21 | if not "%%a" == "Personalization" (
22 | rd /s /q "%%b"
23 | )
24 | )
25 | popd
26 | )
27 | pushd "C:\Users\Default\AppData\Local\Microsoft\" && (
28 | for /f "tokens=*" %%c in ('dir /A:D /b') do (
29 | if not "%%c" == "Windows" if not "%%c" == "Office" if not "%%c" == "Teams" (
30 | rd /s /q "%%c"
31 | )
32 | )
33 | del /f /q *.* 2> nul
34 | del /f /q /ah *.* 2> nul
35 | popd
36 | )
37 | pushd "C:\Users\Default\AppData\Local\" && (
38 | for /f "tokens=*" %%d in ('dir /A:D /b') do (
39 | if not "%%d" == "Microsoft" (
40 | rd /s /q "%%d"
41 | )
42 | )
43 | del /f /q *.* 2> nul
44 | del /f /q /ah *.* 2> nul
45 | popd
46 | )
47 | pushd "C:\Users\Default\AppData\Roaming\Microsoft\Windows" && (
48 | for /f "tokens=*" %%e in ('dir /A:D /b') do (
49 | if not "%%e" == "Start Menu" if not "%%e" == "SendTo" (
50 | rd /s /q "%%e"
51 | )
52 | )
53 | del /f /q *.* 2> nul
54 | del /f /q /ah *.* 2> nul
55 | popd
56 | )
57 | pushd "C:\Users\Default\AppData\Roaming\Microsoft" && (
58 | for /f "tokens=*" %%f in ('dir /A:D /b') do (
59 | if not "%%f" == "Windows" (
60 | rd /s /q "%%f"
61 | )
62 | )
63 | del /f /q *.* 2> nul
64 | del /f /q /ah *.* 2> nul
65 | popd
66 | )
67 | pushd "C:\Users\Default\AppData\Roaming" && (
68 | for /f "tokens=*" %%i in ('dir /A:D /b') do (
69 | if not "%%i" == "Microsoft" if not "%%i" == "Mozilla" (
70 | rd /s /q "%%i"
71 | )
72 | )
73 | del /f /q *.* 2> nul
74 | del /f /q /ah *.* 2> nul
75 | popd
76 | )
77 | for /r %%j in (*.log*) do del /q /f /ah %%j del /q /f %%j
78 | for /r %%k in (*.blf*) do del /q /f /ah %%k del /q /f %%k
79 | for /r %%l in (*.REGTRANS-MS) do del /q /f /ah %%l del /q /f %%l
80 |
81 | echo Default profile cleaned up.
82 | exit
--------------------------------------------------------------------------------
/ScriptFiles/LayoutModification.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ScriptFiles/Set Default Apps.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System]
4 | "DefaultAssociationsConfiguration"="C:\\ProgramData\\Install\\DefaultAssociations.xml"
5 |
6 |
--------------------------------------------------------------------------------
/ScriptFiles/unattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/X_EmergencyFixDefault.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd "C:\Users" && (
3 | for /f "tokens=*" %%a in ('dir /A:D /b') do (
4 | if not "%%a" == "Public" if not "%%a" == "All Users" if not "%%a" == "Default User" (
5 | pushd "C:\Users\%%a\AppData\Local\Microsoft\Windows" && (
6 | rd /s /q WebCache
7 | del /q /f WebCacheLock.dat
8 | )
9 | popd
10 | )
11 | )
12 | popd
13 | )
14 | pause
15 | exit
16 |
--------------------------------------------------------------------------------