├── Packages
├── WindowsStore
│ └── placeholder.txt
└── Win32Calc
│ └── Win32Calc.wim
├── Src
├── GUI
│ ├── image_info.json
│ ├── RemovalTemplates
│ │ ├── ServicesTemplate.json
│ │ ├── FeaturesTemplate.json
│ │ ├── PackagesTemplate.json
│ │ ├── SystemAppsTemplate.json
│ │ ├── WindowsAppsTemplate.json
│ │ └── CapabilitiesTemplate.json
│ ├── setup.ico
│ ├── XAML
│ │ ├── TabLayout.xaml
│ │ ├── MainConfigGroupBox.xaml
│ │ ├── TabScroll.xaml
│ │ ├── InputLayout.xaml
│ │ ├── MainConfigTab.xaml
│ │ ├── ComboBox.xaml
│ │ ├── CheckBox.xaml
│ │ ├── OutputTab.xaml
│ │ ├── ListRemovalComboTab.xaml
│ │ ├── CustomRegistryTab.xaml
│ │ ├── ListRemovalTab.xaml
│ │ └── Layout.xaml
│ └── Configuration_definition.json
├── Public
│ ├── Get-PathSize.ps1
│ ├── Remove-KeyProperty.ps1
│ ├── Compress-Solid.ps1
│ ├── New-Container.ps1
│ ├── Export-DataFile.ps1
│ ├── Stop-Optimize.ps1
│ ├── Invoke-Cleanup.ps1
│ ├── Remove-Container.ps1
│ ├── Dismount-Images.ps1
│ ├── Get-OptionalEnabledFeatures.ps1
│ ├── Export-ErrorLog.ps1
│ ├── Start-Executable.ps1
│ ├── Get-ImageServices.ps1
│ ├── Get-CapabilityPackages.ps1
│ ├── Get-SystemPackages.ps1
│ ├── Get-OptionalDisabledFeatures.ps1
│ ├── Import-DataFile.ps1
│ ├── Get-OtherWindowsPackages.ps1
│ ├── Get-AppxPackages.ps1
│ ├── Test-Requirements.ps1
│ ├── Optimize-InstallMedia.ps1
│ ├── Resolve-FullPath.ps1
│ ├── Import-RegistryTemplates.ps1
│ ├── Set-KeyProperty.ps1
│ ├── DIR2ISO.ps1
│ ├── Set-LockScreen.ps1
│ ├── Get-CompressionType.ps1
│ ├── Get-OfflineHives.ps1
│ ├── Import-Registry.ps1
│ ├── Write-Log.ps1
│ ├── en-US
│ │ └── Set-RegistryProperties.strings.psd1
│ ├── New-ISOMedia.ps1
│ ├── Write-USB.ps1
│ └── Get-ImageData.ps1
└── Private
│ ├── Get-DISMPath.ps1
│ ├── Get-DeploymentTool.ps1
│ ├── Import-Win32API.ps1
│ ├── Grant-KeyAccess.ps1
│ └── Grant-Privilege.ps1
├── Content
├── Lists
│ ├── Capabilities
│ │ ├── CapabilitiesList.json
│ │ └── CapabilitiesTemplate.json
│ ├── Packages
│ │ ├── PackagesList.json
│ │ └── PackagesTemplate.json
│ ├── SystemApps
│ │ ├── SystemAppsList.json
│ │ └── SystemAppsTemplate.json
│ ├── FeaturesToEnable
│ │ ├── FeaturesToEnableList.json
│ │ └── FeaturesToEnableTemplate.json
│ ├── FeaturesToDisable
│ │ ├── FeaturesToDisableList.json
│ │ └── FeaturesToDisableTemplate.json
│ ├── WindowsApps
│ │ ├── WindowsAppsList.json
│ │ └── WindowsAppsTemplate.json
│ └── Services
│ │ ├── ServicesList.json
│ │ ├── ServicesAdvanced.json
│ │ └── ServicesTemplate.json
├── Assets
│ ├── setup.ico
│ └── PlaceAssets.txt
├── Additional
│ ├── Setup
│ │ ├── Set-Additional.cmd
│ │ ├── Remove-OneDrive.cmd
│ │ ├── Services.json
│ │ ├── ScheduledTasks.json
│ │ ├── Remove-DefaultUser0.cmd
│ │ ├── SetupComplete.cmd
│ │ ├── Remove-DefaultUser0.ps1
│ │ ├── README.md
│ │ ├── Refresh-Explorer.ps1
│ │ └── Run_TI_SetupComplete_online.cmd
│ ├── LockScreen
│ │ ├── Win10HD.jpg
│ │ └── README.md
│ ├── SystemLogo
│ │ ├── OEM_LOGO.bmp
│ │ └── README.md
│ ├── Wallpaper
│ │ ├── README.md
│ │ └── Windows 10 HD
│ │ │ ├── AlienHD.jpg
│ │ │ ├── CortanaHD.jpg
│ │ │ ├── DefaultHD.jpg
│ │ │ └── SpaceHD.jpg
│ ├── RegistryTemplates
│ │ ├── README.md
│ │ └── Additional Tweaks.reg
│ ├── Drivers
│ │ ├── Boot
│ │ │ └── README.md
│ │ ├── Install
│ │ │ └── README.md
│ │ └── Recovery
│ │ │ └── README.md
│ ├── LayoutModification
│ │ └── README.md
│ ├── Unattend
│ │ ├── README.md
│ │ ├── auditboot_example.xml
│ │ ├── unattend.xml
│ │ ├── unattend_basic.xml
│ │ └── unattend_example.xml
│ └── SelectiveRegistry
│ │ ├── AMOLED_black_theme.reg
│ │ ├── RunAsTi.reg
│ │ ├── SelectiveRegistry.ps1
│ │ └── WindowsPhotoViewer.reg
└── CustomAppAssociations.xml
├── .gitattributes
├── populateLists.bat
├── populateTemplates.bat
├── Start-helper.ps1
├── .gitignore
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── Start-Optimize.bat
├── Start-GUI.bat
├── LICENSE
├── Upcoming.md
├── Optimize-Offline.psd1
├── Configuration.json
├── Remove_Failure_no_prompts.cmd
├── ChangeLog.md
├── Start-Optimize.ps1
├── Start-Optimize-BAU-TI.ps1
└── en-US
└── Optimize-Offline.strings.psd1
/Packages/WindowsStore/placeholder.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Src/GUI/image_info.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/Src/GUI/RemovalTemplates/ServicesTemplate.json:
--------------------------------------------------------------------------------
1 | [
2 |
3 | ]
--------------------------------------------------------------------------------
/Src/GUI/RemovalTemplates/FeaturesTemplate.json:
--------------------------------------------------------------------------------
1 | [
2 |
3 | ]
4 |
--------------------------------------------------------------------------------
/Src/GUI/RemovalTemplates/PackagesTemplate.json:
--------------------------------------------------------------------------------
1 | [
2 |
3 | ]
4 |
--------------------------------------------------------------------------------
/Src/GUI/RemovalTemplates/SystemAppsTemplate.json:
--------------------------------------------------------------------------------
1 | [
2 |
3 | ]
--------------------------------------------------------------------------------
/Src/GUI/RemovalTemplates/WindowsAppsTemplate.json:
--------------------------------------------------------------------------------
1 | [
2 |
3 | ]
--------------------------------------------------------------------------------
/Src/GUI/RemovalTemplates/CapabilitiesTemplate.json:
--------------------------------------------------------------------------------
1 | [
2 |
3 | ]
4 |
--------------------------------------------------------------------------------
/Content/Lists/Capabilities/CapabilitiesList.json:
--------------------------------------------------------------------------------
1 | {
2 | "Name": [
3 |
4 | ]
5 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/Content/Lists/Packages/PackagesList.json:
--------------------------------------------------------------------------------
1 | {
2 | "PackageName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Lists/SystemApps/SystemAppsList.json:
--------------------------------------------------------------------------------
1 | {
2 | "DisplayName": [
3 |
4 | ]
5 | }
--------------------------------------------------------------------------------
/Src/GUI/setup.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Src/GUI/setup.ico
--------------------------------------------------------------------------------
/Content/Lists/FeaturesToEnable/FeaturesToEnableList.json:
--------------------------------------------------------------------------------
1 | {
2 | "FeatureName" : [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/populateLists.bat:
--------------------------------------------------------------------------------
1 | powershell -ExecutionPolicy Bypass -File "%~dp0Start-Optimize.ps1" "-populateLists"
--------------------------------------------------------------------------------
/Content/Lists/FeaturesToDisable/FeaturesToDisableList.json:
--------------------------------------------------------------------------------
1 | {
2 | "FeatureName" : [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/populateTemplates.bat:
--------------------------------------------------------------------------------
1 | powershell -ExecutionPolicy Bypass -File "%~dp0Start-Optimize.ps1" "-populateTemplates"
--------------------------------------------------------------------------------
/Content/Assets/setup.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Assets/setup.ico
--------------------------------------------------------------------------------
/Content/Additional/Setup/Set-Additional.cmd:
--------------------------------------------------------------------------------
1 | PowerShell -NoProfile -ExecutionPolicy Bypass -File ".\Set-Additional.ps1"
--------------------------------------------------------------------------------
/Content/Lists/WindowsApps/WindowsAppsList.json:
--------------------------------------------------------------------------------
1 | {
2 | "DisplayName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Lists/Capabilities/CapabilitiesTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "Name": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Packages/Win32Calc/Win32Calc.wim:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Packages/Win32Calc/Win32Calc.wim
--------------------------------------------------------------------------------
/Content/Additional/Setup/Remove-OneDrive.cmd:
--------------------------------------------------------------------------------
1 | PowerShell -NoProfile -ExecutionPolicy Bypass -File ".\Remove-OneDrive.ps1"
2 |
3 |
--------------------------------------------------------------------------------
/Content/Lists/Packages/PackagesTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "PackageName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Additional/Setup/Services.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/Setup/Services.json
--------------------------------------------------------------------------------
/Content/Lists/FeaturesToEnable/FeaturesToEnableTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "FeatureName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Additional/LockScreen/Win10HD.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/LockScreen/Win10HD.jpg
--------------------------------------------------------------------------------
/Content/Lists/FeaturesToDisable/FeaturesToDisableTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "FeatureName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Lists/SystemApps/SystemAppsTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "DisplayName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Lists/WindowsApps/WindowsAppsTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "DisplayName": [
3 |
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/Content/Additional/SystemLogo/OEM_LOGO.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/SystemLogo/OEM_LOGO.bmp
--------------------------------------------------------------------------------
/Content/Additional/Setup/ScheduledTasks.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/Setup/ScheduledTasks.json
--------------------------------------------------------------------------------
/Content/Additional/Wallpaper/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any wallpaper files and/or folders to be added to the image here.
2 |
--------------------------------------------------------------------------------
/Content/Additional/RegistryTemplates/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any registration templates (reg files) to be added to the image here.
2 |
--------------------------------------------------------------------------------
/Content/Assets/PlaceAssets.txt:
--------------------------------------------------------------------------------
1 | Place different assets here
2 | You can place windows.ico - used as the windows local disk icon
3 | setup.ico - used as the USB/ISO icon
--------------------------------------------------------------------------------
/Content/Additional/Drivers/Boot/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any driver .inf file(s) or full driver packages to be injected to the boot image here.
2 |
--------------------------------------------------------------------------------
/Content/Additional/Wallpaper/Windows 10 HD/AlienHD.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/Wallpaper/Windows 10 HD/AlienHD.jpg
--------------------------------------------------------------------------------
/Content/Additional/Wallpaper/Windows 10 HD/CortanaHD.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/Wallpaper/Windows 10 HD/CortanaHD.jpg
--------------------------------------------------------------------------------
/Content/Additional/Wallpaper/Windows 10 HD/DefaultHD.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/Wallpaper/Windows 10 HD/DefaultHD.jpg
--------------------------------------------------------------------------------
/Content/Additional/Wallpaper/Windows 10 HD/SpaceHD.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/Wallpaper/Windows 10 HD/SpaceHD.jpg
--------------------------------------------------------------------------------
/Src/GUI/XAML/TabLayout.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {TabContent}
4 |
5 |
--------------------------------------------------------------------------------
/Content/Additional/Drivers/Install/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any driver .inf file(s) or full driver packages to be injected to the install image here.
--------------------------------------------------------------------------------
/Content/Additional/RegistryTemplates/Additional Tweaks.reg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gdeliana/Optimize-Offline/HEAD/Content/Additional/RegistryTemplates/Additional Tweaks.reg
--------------------------------------------------------------------------------
/Content/Additional/Drivers/Recovery/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any driver .inf file(s) or full driver packages to be injected to the recovery image here.
2 |
--------------------------------------------------------------------------------
/Src/GUI/XAML/MainConfigGroupBox.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {Content}
4 |
5 |
--------------------------------------------------------------------------------
/Content/Additional/LayoutModification/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any custom Start Menu layout XML/JSON (LayoutModification.xml/LayoutModification.json) file to be added to the image here.
2 |
--------------------------------------------------------------------------------
/Src/GUI/XAML/TabScroll.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {TabContent}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Content/Lists/Services/ServicesList.json:
--------------------------------------------------------------------------------
1 | {
2 | "__Info": [
3 | "Insert the services display names as a list, the names are found in the ./ServicesTemplate.json in the 'name' key"
4 | ],
5 | "Services": [
6 |
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/Content/Additional/SystemLogo/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place custom logo image file to be added to the image here.
2 |
3 | Only the bitmap file format (.bmp) with a dimension of 120x120 is supported by Windows
4 |
--------------------------------------------------------------------------------
/Content/Additional/LockScreen/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any custom LockScreen image file to be added to the image here.
2 |
3 | The image must be in .jpg format and have dimensions appropriate for the resolution (1920x1080)
4 |
--------------------------------------------------------------------------------
/Content/Lists/Services/ServicesAdvanced.json:
--------------------------------------------------------------------------------
1 | {
2 | "__Info": [
3 | "start key values",
4 | "0 = Boot",
5 | "1 = System",
6 | "2 = Automatic",
7 | "3 = Manual",
8 | "4 = Disabled"
9 | ],
10 | "Services": [
11 |
12 | ]
13 | }
--------------------------------------------------------------------------------
/Start-helper.ps1:
--------------------------------------------------------------------------------
1 | $scriptPath = '.\Start-Optimize.ps1'
2 | $process = Start-Process -FilePath "powershell.exe" -ArgumentList ("-NoExit", "-ExecutionPolicy Bypass", "-File `"$scriptPath`"") -PassThru
3 | $process | Wait-Process
4 |
5 | & .\Remove_Failure_no_prompts.cmd
--------------------------------------------------------------------------------
/Src/Public/Get-PathSize.ps1:
--------------------------------------------------------------------------------
1 | Function Get-PathSize {
2 | Param
3 | (
4 | [Parameter(Mandatory = $true)]
5 | [String]$Path
6 | )
7 | $size = 0
8 | Get-ChildItem $Path -Recurse -File | ForEach-Object {
9 | $size += $_.Length
10 | }
11 | return $size
12 | }
--------------------------------------------------------------------------------
/Src/GUI/XAML/InputLayout.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {Input}
10 |
--------------------------------------------------------------------------------
/Src/GUI/XAML/MainConfigTab.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | {ColsXAML}
10 |
11 |
--------------------------------------------------------------------------------
/Content/Lists/Services/ServicesTemplate.json:
--------------------------------------------------------------------------------
1 | {
2 | "__Info": [
3 | "start key values",
4 | "0 = Boot",
5 | "1 = System",
6 | "2 = Automatic",
7 | "3 = Manual",
8 | "4 = Disabled"
9 | ],
10 | "Services": [
11 |
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/Src/GUI/XAML/ComboBox.xaml:
--------------------------------------------------------------------------------
1 |
2 |
12 | {Items}
13 |
--------------------------------------------------------------------------------
/Content/Additional/Unattend/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place an unattend.xml to be imported into the image here.
2 |
3 | Because this unattend.xml answer file gets applied directly to the image, and is copied to the %WINDIR%\Panther directory, it will act indentically to an autounattend.xml answer file placed on the installation media with the exception of the WindowsPE configuration pass. Any WindowsPE configuration pass parameters must be placed in an autounattend.xml in order to set up disk partitions and layouts.
4 |
--------------------------------------------------------------------------------
/Content/Additional/Setup/Remove-DefaultUser0.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | CD /D "%~dp0"
3 |
4 | NET SESSION >NUL 2>&1
5 | IF %ERRORLEVEL% NEQ 0 (
6 | ECHO Permission denied. This script must be run as an Administrator.
7 | ECHO:
8 | PAUSE
9 | EXIT
10 | ) ELSE (
11 | PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File .\Remove-DefaultUser0.ps1 -Argument 2> .\Remove-DefaultUser0.error
12 | DEL /F /Q "%~dp0Remove-DefaultUser0.error" >NUL 2>&1
13 | DEL /F /Q "%~dp0Remove-DefaultUser0.ps1" >NUL 2>&1
14 | DEL /F /Q "%~f0" >NUL 2>&1
15 | )
16 | PAUSE
17 | EXIT
18 |
19 |
--------------------------------------------------------------------------------
/Content/Additional/Setup/SetupComplete.cmd:
--------------------------------------------------------------------------------
1 | CD /D "%~dp0"
2 |
3 | REM Answer files should ALWAYS be removed from the 'Windows\Panther' and 'Windows\System32\Sysprep' directories immediately after they've been processed.
4 |
5 | PowerShell.exe -NoProfile -ExecutionPolicy Bypass -File "%WINDIR%\Setup\Scripts\Refresh-Explorer.ps1"
6 | DEL /F /Q "%WINDIR%\Setup\Scripts\Refresh-Explorer.ps1" >NUL 2>&1
7 | DEL /F /Q "%WINDIR%\Setup\Scripts\Run_TI_SetupComplete_online.cmd >NUL 2>&1
8 | DEL /F /Q "%WINDIR%\Panther\unattend.xml" >NUL 2>&1
9 | DEL /F /Q "%WINDIR%\System32\Sysprep\unattend.xml" >NUL 2>&1
10 | DEL "%~f0"
11 |
--------------------------------------------------------------------------------
/Content/Additional/Unattend/auditboot_example.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Audit
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/*
2 | !.vscode/settings.json
3 | !.vscode/tasks.json
4 | !.vscode/launch.json
5 | !.vscode/extensions.json
6 | .history
7 | Thumbs.db
8 | Thumbs.db:encryptable
9 | ehthumbs.db
10 | ehthumbs_vista.db
11 | *.stackdump
12 | [Dd]esktop.ini
13 | $RECYCLE.BIN/
14 | #*.cab
15 | *.dll
16 | *.lnk
17 | *.msi
18 | *.msix
19 | *.msm
20 | *.msp
21 | *.psproj
22 | *.psprojs
23 | *.TempPoint.*
24 | *.Export.*
25 | *.RestorePoint.*
26 | *.Run.ps1
27 | *.Package.ps1
28 | CustomMenu.inf
29 | *.zip
30 | ChangeLog_Full.md
31 | /Optimize-Offline_*
32 | /OfflineTemp*
33 | /Src/GUI/image_info.json
34 | /ConsoleOut.txt
35 |
--------------------------------------------------------------------------------
/Src/Private/Get-DISMPath.ps1:
--------------------------------------------------------------------------------
1 | Function Get-DISMPath
2 | {
3 | [CmdletBinding()]
4 | [OutputType([IO.DirectoryInfo])]
5 | Param ()
6 |
7 | [IO.DirectoryInfo]$DISMPath = @("HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots", "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots") | ForEach-Object -Process { Get-ItemProperty -Path $PSItem -ErrorAction Ignore } | Select-Object -Unique -ExpandProperty KitsRoot10 -ErrorAction Ignore | Join-Path -ChildPath "Assessment and Deployment Kit\Deployment Tools\$Env:PROCESSOR_ARCHITECTURE\DISM" -ErrorAction Ignore
8 | If ($DISMPath.Exists) { $DISMPath.FullName }
9 | }
--------------------------------------------------------------------------------
/Src/GUI/XAML/CheckBox.xaml:
--------------------------------------------------------------------------------
1 |
11 | {Label}
12 |
13 |
16 |
17 |
18 | {Tooltip}
19 |
20 |
--------------------------------------------------------------------------------
/Src/Public/Remove-KeyProperty.ps1:
--------------------------------------------------------------------------------
1 | Function Remove-KeyProperty
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | ValueFromPipeline = $true,
8 | ValueFromPipelineByPropertyName = $true)]
9 | [Alias('FullName', 'PSPath')]
10 | [String]$Path,
11 | [Parameter(Mandatory = $true)]
12 | [String]$Name
13 | )
14 |
15 | Process
16 | {
17 | Try { Get-ItemProperty -LiteralPath $Path -Name $Name -ErrorAction Stop | Remove-ItemProperty -Name $Name -Force }
18 | Catch [Management.Automation.PSArgumentException] { Break }
19 | }
20 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[REQUEST]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/Src/Public/Compress-Solid.ps1:
--------------------------------------------------------------------------------
1 | Function Compress-Solid
2 | {
3 | [CmdletBinding()]
4 | [OutputType([IO.FileInfo])]
5 | Param ()
6 |
7 | $ImageInfo = Import-DataFile Install -ErrorAction:$ErrorActionPreference
8 | $DestinationImage = '{0}\{1}' -f $ImageFolder, [IO.Path]::ChangeExtension((GetPath -Path $ImageInfo.Path -Split Leaf), '.esd')
9 | $RET = StartExe $DISM -Arguments ('/Export-Image /SourceImageFile:"{0}" /SourceIndex:{1} /DestinationImageFile:"{2}" /Compress:Recovery /CheckIntegrity /ScratchDir:"{3}" /LogPath:"{4}" /LogLevel:1' -f $ImageInfo.Path, $ImageInfo.Index, $DestinationImage, $ScratchFolder, $DISMLog) -ErrorAction:$ErrorActionPreference
10 | If ($RET -eq 0) { Get-Item -Path $DestinationImage -ErrorAction:$ErrorActionPreference }
11 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a bug report
4 | title: "[BUG]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **Screenshots**
14 | If applicable, add screenshots to help explain your problem.
15 |
16 | **Please complete the following information:**
17 |
18 | - Image Name: [e.g. Windows 10 Pro]
19 | - Image Build: [e.g. 17763]
20 | - Host Environment: [e.g. Windows 10 Pro]
21 | - Parameters Passed: [e.g -WindowsApps "All" -SystemApps -Capabilities -Packages -Features]
22 |
23 | **Additional content or data**
24 | Add any other pertinent content or data.
25 |
26 | **Log files**
27 | Add any log files produced.
28 |
--------------------------------------------------------------------------------
/Src/Public/New-Container.ps1:
--------------------------------------------------------------------------------
1 | Function New-Container
2 | {
3 | [CmdletBinding()]
4 | [OutputType([IO.FileSystemInfo])]
5 | Param
6 | (
7 | [Parameter(Mandatory = $true,
8 | ValueFromPipeline = $true,
9 | ValueFromPipelineByPropertyName = $true)]
10 | [Alias('FullName', 'PSPath')]
11 | [String[]]$Path,
12 | [Switch]$PassThru
13 | )
14 |
15 | Process
16 | {
17 | ForEach ($Item In $Path)
18 | {
19 | If (!(Test-Path -LiteralPath $Item))
20 | {
21 | $RET = New-Item -Path $Item -ItemType Directory -Force -ErrorAction:$ErrorActionPreference
22 | If ($PassThru.IsPresent) { $RET }
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Src/Public/Export-DataFile.ps1:
--------------------------------------------------------------------------------
1 | Function Export-DataFile
2 | {
3 | [CmdletBinding()]
4 | [OutputType([IO.FileInfo])]
5 | Param
6 | (
7 | [Parameter(Mandatory = $true,
8 | ValueFromPipeline = $true,
9 | Position = 0)]
10 | [PSObject]$Data,
11 | [Parameter(Mandatory = $true,
12 | Position = 1)]
13 | [String]$File,
14 | [Switch]$PassThru
15 | )
16 |
17 | Process
18 | {
19 | If ([IO.Path]::GetExtension($File) -ne '.XML') { $File = [IO.Path]::ChangeExtension($File, '.xml') }
20 | $Data | Export-Clixml -Path (GetPath -Path $WorkFolder -Child $File) -Force -ErrorAction SilentlyContinue
21 | If ($PassThru.IsPresent) { GetPath -Path $WorkFolder -Child $File }
22 | }
23 | }
--------------------------------------------------------------------------------
/Src/Public/Stop-Optimize.ps1:
--------------------------------------------------------------------------------
1 | Function Stop-Optimize
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | Log $OptimizeData.TerminatingOptimizations -Failed
7 | Dismount-Images
8 | $SaveDirectory = Create -Path (GetPath -Path $OptimizeOffline.Directory -Child Optimize-Offline_$((Get-Date).ToString('yyyy-MM-ddThh.mm.ss'))) -PassThru
9 | @($DISMLog, (GetPath -Path $Env:SystemRoot -Child 'Logs\DISM\dism.log')) | Purge -ErrorAction Ignore
10 | If ($Global:Error.Count -gt 0 -or $OptimizeErrors.Count -gt 0) { Export-ErrorLog -ErrorAction Ignore }
11 | Get-ChildItem -Path $LogFolder -Filter *.log | Move-Item -Destination $SaveDirectory.FullName -Force
12 | $TempDirectory | Purge
13 | $Global:Error.Clear()
14 | ((Compare-Object -ReferenceObject (Get-Variable).Name -DifferenceObject $LocalScope.Variables).InputObject).ForEach{ Remove-Variable -Name $PSItem -ErrorAction Ignore }
15 | (Get-Process -Id $PID).Kill()
16 | }
--------------------------------------------------------------------------------
/Src/GUI/XAML/OutputTab.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
29 |
--------------------------------------------------------------------------------
/Src/Public/Invoke-Cleanup.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-Cleanup
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [ValidateSet('Install', 'Boot', 'Recovery')]
7 | [String]$Image = 'Install'
8 | )
9 |
10 | $MountPath = Switch ($PSBoundParameters.Image)
11 | {
12 | 'Install' { $InstallMount; Break }
13 | 'Boot' { $BootMount; Break }
14 | 'Recovery' { $RecoveryMount; Break }
15 | }
16 |
17 | @((GetPath -Path $MountPath -Child "Windows\WinSxS\Temp\PendingDeletes\*"), (GetPath -Path $MountPath -Child "Windows\WinSxS\Temp\TransformerRollbackData\*"), (GetPath -Path $MountPath -Child "Windows\WinSxS\ManifestCache\*.bin")) | Purge -Force -ErrorAction Ignore
18 | @((GetPath -Path $MountPath -Child PerfLogs), (GetPath -Path $MountPath -Child "Windows\INF\*.log"), (GetPath -Path $MountPath -Child "Windows\CbsTemp\*"), ("$MountPath\" + '$Recycle.Bin')) | Purge -ErrorAction Ignore
19 | }
--------------------------------------------------------------------------------
/Src/Public/Remove-Container.ps1:
--------------------------------------------------------------------------------
1 | Function Remove-Container
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | ValueFromPipeline = $true,
8 | ValueFromPipelineByPropertyName = $true)]
9 | [Alias('FullName', 'PSPath')]
10 | [String[]]$Path,
11 | [Switch]$Force
12 | )
13 |
14 | Begin
15 | {
16 | If ($Force.IsPresent) { 'SeTakeOwnershipPrivilege', 'SeBackupPrivilege', 'SeRestorePrivilege' | Grant-Privilege }
17 | }
18 | Process
19 | {
20 | ForEach ($Item In $Path)
21 | {
22 | If (Test-Path -LiteralPath $Item) { Remove-Item -LiteralPath $Item -Recurse -Force -ErrorAction:$ErrorActionPreference }
23 | }
24 | }
25 | End
26 | {
27 | If ($Force.IsPresent) { 'SeTakeOwnershipPrivilege', 'SeBackupPrivilege', 'SeRestorePrivilege' | Grant-Privilege -Disable }
28 | }
29 | }
--------------------------------------------------------------------------------
/Src/GUI/XAML/ListRemovalComboTab.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 | {Columns}
17 |
18 |
19 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Src/Public/Dismount-Images.ps1:
--------------------------------------------------------------------------------
1 | Function Dismount-Images
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | If (Get-WindowsImage -Mounted)
7 | {
8 | $Host.UI.RawUI.WindowTitle = $OptimizeData.ActiveMountPoints
9 | Write-Host $OptimizeData.ActiveMountPoints -ForegroundColor Cyan
10 | RegHives -Unload
11 | If (Invoke-Expression -Command ('REG QUERY HKLM | FINDSTR Optimize-Offline'))
12 | {
13 | [GC]::Collect()
14 | Invoke-Expression -Command ('REG QUERY HKLM | FINDSTR Optimize-Offline') | ForEach-Object -Process { [Void](StartExe $REG -Arguments ('UNLOAD {0}' -f $PSItem)) }
15 | }
16 | Get-WindowsImage -Mounted | ForEach-Object -Process {
17 | If ($PSItem.ImagePath -match 'boot.wim' -or $PSItem.ImagePath -match 'winre.wim' -or $PSItem.ImagePath -match 'install.wim') { [Void](Dismount-WindowsImage -Path $PSItem.MountPath -Discard) }
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Src/Private/Get-DeploymentTool.ps1:
--------------------------------------------------------------------------------
1 | Function Get-DeploymentTool
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'DISM')]
4 | [OutputType([IO.DirectoryInfo])]
5 | Param
6 | (
7 | [Parameter(ParameterSetName = 'DISM',
8 | Position = 0)]
9 | [Switch]$DISM,
10 | [Parameter(ParameterSetName = 'OSCDIMG',
11 | Position = 0)]
12 | [Switch]$OSCDIMG
13 | )
14 |
15 | [IO.DirectoryInfo]$DeploymentTool = @("HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots") | ForEach-Object -Process { Get-ItemProperty -Path $PSItem -ErrorAction Ignore } | Select-Object -Unique -ExpandProperty KitsRoot10 -ErrorAction Ignore | Join-Path -ChildPath ("Assessment and Deployment Kit\Deployment Tools\$Env:PROCESSOR_ARCHITECTURE\{0}" -f $PSCmdlet.ParameterSetName) -ErrorAction Ignore
16 | If ($DeploymentTool.Exists) { $DeploymentTool.FullName }
17 | }
--------------------------------------------------------------------------------
/Src/GUI/XAML/CustomRegistryTab.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
29 |
--------------------------------------------------------------------------------
/Src/Public/Get-OptionalEnabledFeatures.ps1:
--------------------------------------------------------------------------------
1 | Function Get-OptionalEnabledFeatures {
2 |
3 | [CmdletBinding()]
4 |
5 | Param (
6 | [Parameter(Mandatory = $true,
7 | HelpMessage = 'full path to the root directory of the offline Windows image that you will service.')]
8 | [String]$Path,
9 | [Parameter(Mandatory = $false,
10 | HelpMessage = 'Specifies a temporary directory that will be used when extracting files for use during servicing. The directory must exist locally. If not specified, the \Windows\%Temp% directory will be used')]
11 | [String]$ScratchDirectory,
12 | [Parameter(Mandatory = $false,
13 | HelpMessage = 'the full path and file name to log to. If not set, the default is %WINDIR%\Logs\Dism\dism.log')]
14 | [String]$LogPath
15 | )
16 |
17 | return Get-WindowsOptionalFeature -Path $Path -ScratchDirectory $ScratchDirectory -LogPath $LogPath -LogLevel 1 | Select-Object -Property FeatureName, State | Sort-Object -Property FeatureName | Where-Object -Property State -EQ Enabled
18 | }
--------------------------------------------------------------------------------
/Content/Additional/Unattend/unattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | true
7 | true
8 | true
9 | true
10 | 3
11 | false
12 |
13 | false
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Start-Optimize.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | :: BatchGotAdmin
4 | :-------------------------------------
5 | REM --> Check for permissions
6 | IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
7 | >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
8 | ) ELSE (
9 | >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
10 | )
11 |
12 | REM --> If error flag set, we do not have admin.
13 | if '%errorlevel%' NEQ '0' (
14 | echo Requesting administrative privileges...
15 | goto UACPrompt
16 | ) else ( goto gotAdmin )
17 |
18 | :UACPrompt
19 | echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
20 | set params= %*
21 | echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
22 |
23 | "%temp%\getadmin.vbs"
24 | del "%temp%\getadmin.vbs"
25 | exit /B
26 |
27 | :gotAdmin
28 | pushd "%CD%"
29 | CD /D "%~dp0"
30 |
31 |
32 |
33 | powershell -ExecutionPolicy Bypass -File "%~dp0Start-helper.ps1"
34 | pause
--------------------------------------------------------------------------------
/Content/Additional/Unattend/unattend_basic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | true
7 | true
8 | true
9 | true
10 | 3
11 | false
12 |
13 | false
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Src/Public/Export-ErrorLog.ps1:
--------------------------------------------------------------------------------
1 | Function Export-ErrorLog
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | If ($Global:Error.Count -gt 0 -or $OptimizeErrors.Count -gt 0)
7 | {
8 | $Index = 0
9 | ($Global:Error + $OptimizeErrors | ForEach-Object -Process {
10 | [PSCustomObject]@{
11 | Index = $Index
12 | Exception = $PSItem.Exception.Message
13 | Category = $PSItem.CategoryInfo.ToString()
14 | ErrorID = $PSItem.FullyQualifiedErrorId
15 | Target = $PSItem.TargetObject
16 | Command = $PSItem.InvocationInfo.Line.Trim()
17 | Script = $PSItem.InvocationInfo.ScriptName
18 | Line = $PSItem.InvocationInfo.ScriptLineNumber
19 | Column = $PSItem.InvocationInfo.OffsetInLine
20 | }
21 | $Index++
22 | } | Out-String).Trim() | Out-File -FilePath $ErrorLog -Encoding UTF8 -Force -ErrorAction Ignore
23 | }
24 | }
--------------------------------------------------------------------------------
/Src/Public/Start-Executable.ps1:
--------------------------------------------------------------------------------
1 | Function Start-Executable
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true)]
7 | [IO.FileInfo]$Executable,
8 | [String[]]$Arguments
9 | )
10 |
11 | Begin
12 | {
13 | $ProcessInfo = New-Object -TypeName Diagnostics.ProcessStartInfo -ErrorAction:$ErrorActionPreference
14 | $ProcessInfo.FileName = $Executable.FullName
15 | If (![String]::IsNullOrEmpty($Arguments)) { $ProcessInfo.Arguments = $Arguments }
16 | $ProcessInfo.CreateNoWindow = $true
17 | $ProcessInfo.WindowStyle = 'Hidden'
18 | $ProcessInfo.UseShellExecute = $false
19 | $ProcessRun = New-Object -TypeName Diagnostics.Process -ErrorAction:$ErrorActionPreference
20 | $ProcessRun.StartInfo = $ProcessInfo
21 | }
22 | Process
23 | {
24 | [Void]$ProcessRun.Start()
25 | $ProcessRun.WaitForExit()
26 | $ProcessRun.ExitCode
27 | }
28 | End
29 | {
30 | If ($null -ne $ProcessRun) { $ProcessRun.Dispose() }
31 | }
32 | }
--------------------------------------------------------------------------------
/Src/Private/Import-Win32API.ps1:
--------------------------------------------------------------------------------
1 | Function Import-Win32API
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'Load')]
4 | Param
5 | (
6 | [Parameter(ParameterSetName = 'Load')]
7 | [Switch]$Load,
8 | [Parameter(ParameterSetName = 'Unload')]
9 | [Switch]$Unload
10 | )
11 |
12 | $Win32APIParams = @{ Namespace = 'Win32API'; PassThru = $true }
13 | Switch ($PSCmdlet.ParameterSetName)
14 | {
15 | 'Load'
16 | {
17 | $Win32APIParams.MemberDefinition = '[DllImport("advapi32.dll", SetLastError = true)] public static extern Int32 RegLoadKey(Int32 hKey, String lpSubKey, String lpFile);'
18 | $Win32APIParams.Name = 'Win32RegLoad'
19 | Break
20 | }
21 | 'Unload'
22 | {
23 | $Win32APIParams.MemberDefinition = '[DllImport("advapi32.dll", SetLastError = true)] public static extern Int32 RegUnLoadKey(Int32 hKey, String lpSubKey);'
24 | $Win32APIParams.Name = 'Win32RegUnLoad'
25 | Break
26 | }
27 | }
28 | Add-Type @Win32APIParams
29 | }
--------------------------------------------------------------------------------
/Src/Public/Get-ImageServices.ps1:
--------------------------------------------------------------------------------
1 | Function Get-ImageServices {
2 | $ServicesStartLabels = @(
3 | "Boot",
4 | "System",
5 | "Automatic",
6 | "Manual",
7 | "Disabled"
8 | )
9 | $RegPath = "HKLM:\WIM_HKLM_SYSTEM\ControlSet001\Services"
10 | $Services = [System.Collections.ArrayList]@();
11 | Get-ChildItem -Path $RegPath | Where-Object{$_.ValueCount -gt 0} | ForEach-Object -Process {
12 |
13 | $ServiceDetails = Get-Service -Name $PSItem.PSChildName -ErrorAction Ignore
14 |
15 | $FolderKeys = Get-ItemProperty -Path "$RegPath\$($PSItem.PSChildName)"
16 |
17 | If($null -ne $FolderKeys.Start -and $null -eq $FolderKeys.Owners -and $FolderKeys.Start -ne 4 -and $FolderKeys.Start -gt 1){
18 | $O = New-Object PSObject -Property @{
19 | name = [String]$PSItem.PSChildName
20 | description = $(If ($null -ne $ServiceDetails -and $null -ne $ServiceDetails.DisplayName) {$ServiceDetails.DisplayName} Else {""})
21 | start = $FolderKeys.Start
22 | startLabel = $ServicesStartLabels[$FolderKeys.Start]
23 | }
24 | [void]$Services.Add($O)
25 | }
26 | }
27 |
28 | return $Services
29 | }
--------------------------------------------------------------------------------
/Start-GUI.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | :: BatchGotAdmin
4 | :-------------------------------------
5 | REM --> Check for permissions
6 | IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
7 | >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
8 | ) ELSE (
9 | >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
10 | )
11 |
12 | REM --> If error flag set, we do not have admin.
13 | if '%errorlevel%' NEQ '0' (
14 | echo Requesting administrative privileges...
15 | goto UACPrompt
16 | ) else ( goto gotAdmin )
17 |
18 | :UACPrompt
19 | echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
20 | set params= %*
21 | echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
22 |
23 | "%temp%\getadmin.vbs"
24 | del "%temp%\getadmin.vbs"
25 | exit /B
26 |
27 | :gotAdmin
28 | pushd "%CD%"
29 | CD /D "%~dp0"
30 |
31 |
32 | start /wait powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File "%~dp0Src\GUI\Start.ps1"
33 | call "Remove_Failure_no_prompts.cmd"
34 | pause
--------------------------------------------------------------------------------
/Src/Public/Get-CapabilityPackages.ps1:
--------------------------------------------------------------------------------
1 | Function Get-CapabilityPackages {
2 |
3 | [CmdletBinding()]
4 |
5 | Param (
6 | [Parameter(Mandatory = $true,
7 | HelpMessage = 'full path to the root directory of the offline Windows image that you will service.')]
8 | [String]$Path,
9 | [Parameter(Mandatory = $false,
10 | HelpMessage = 'Specifies a temporary directory that will be used when extracting files for use during servicing. The directory must exist locally. If not specified, the \Windows\%Temp% directory will be used')]
11 | [String]$ScratchDirectory,
12 | [Parameter(Mandatory = $false,
13 | HelpMessage = 'the full path and file name to log to. If not set, the default is %WINDIR%\Logs\Dism\dism.log')]
14 | [String]$LogPath
15 | )
16 |
17 | $WindowsCapabilities = Get-WindowsCapability -Path $Path -ScratchDirectory $ScratchDirectory -LogPath $LogPath -LogLevel 1 | Where-Object { $PSItem.Name -notlike "*Language.Basic*" -and $PSItem.Name -notlike "*TextToSpeech*" -and $PSItem.State -eq 'Installed' } | Select-Object -Property Name, State | Sort-Object -Property Name
18 |
19 | return $WindowsCapabilities
20 |
21 | }
--------------------------------------------------------------------------------
/Src/Public/Get-SystemPackages.ps1:
--------------------------------------------------------------------------------
1 | Function Get-SystemPackages {
2 |
3 | $RegKeyPath = "HKLM:\WIM_HKLM_SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications"
4 |
5 | RegHives -Load
6 |
7 | If (!(Test-Path -Path $RegKeyPath)) {
8 | return @()
9 | }
10 |
11 | $InboxAppsPackages = Get-ChildItem -Path $RegKeyPath -Name | ForEach-Object -Process {
12 | $DisplayName = $PSItem.Split('_')[0]; $PackageName = $PSItem
13 | If ($DisplayName -like '1527c705-839a-4832-9118-54d4Bd6a0c89') { $DisplayName = 'Microsoft.Windows.FilePicker' }
14 | If ($DisplayName -like 'c5e2524a-ea46-4f67-841f-6a9465d9d515') { $DisplayName = 'Microsoft.Windows.FileExplorer' }
15 | If ($DisplayName -like 'E2A4F912-2574-4A75-9BB0-0D023378592B') { $DisplayName = 'Microsoft.Windows.AppResolverUX' }
16 | If ($DisplayName -like 'F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE') { $DisplayName = 'Microsoft.Windows.AddSuggestedFoldersToLibarayDialog' }
17 | [PSCustomObject]@{ DisplayName = $DisplayName; PackageName = $PackageName }
18 | } | Sort-Object -Property DisplayName
19 |
20 | RegHives -Unload
21 |
22 | return $InboxAppsPackages
23 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 DrEmpiricism
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 |
--------------------------------------------------------------------------------
/Src/Public/Get-OptionalDisabledFeatures.ps1:
--------------------------------------------------------------------------------
1 | Function Get-OptionalDisabledFeatures {
2 |
3 | [CmdletBinding()]
4 |
5 | Param (
6 | [Parameter(Mandatory = $true,
7 | HelpMessage = 'full path to the root directory of the offline Windows image that you will service.')]
8 | [String]$Path,
9 | [Parameter(Mandatory = $false,
10 | HelpMessage = 'Specifies a temporary directory that will be used when extracting files for use during servicing. The directory must exist locally. If not specified, the \Windows\%Temp% directory will be used')]
11 | [String]$ScratchDirectory,
12 | [Parameter(Mandatory = $false,
13 | HelpMessage = 'the full path and file name to log to. If not set, the default is %WINDIR%\Logs\Dism\dism.log')]
14 | [String]$LogPath
15 | )
16 |
17 | return Get-WindowsOptionalFeature -Path $Path -ScratchDirectory $ScratchDirectory -LogPath $LogPath -LogLevel 1 | Select-Object -Property FeatureName, State | Sort-Object -Property FeatureName | Where-Object { $PSItem.FeatureName -notlike "SMB1Protocol*" -and $PSItem.FeatureName -ne "Windows-Defender-Default-Definitions" -and $PSItem.FeatureName -notlike "MicrosoftWindowsPowerShellV2*" -and $PSItem.State -eq "Disabled" }
18 | }
--------------------------------------------------------------------------------
/Content/Additional/Setup/Remove-DefaultUser0.ps1:
--------------------------------------------------------------------------------
1 | If (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
2 | {
3 | [IO.DirectoryInfo]$ProfilePath = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" | ForEach-Object -Process { $PSItem.GetValue('ProfileImagePath') } | Where-Object { $PSItem -like "*defaultuser0*" }
4 | If ($ProfilePath.Exists)
5 | {
6 | Clear-Host
7 | Write-Host "Removing the DefaultUser0 profile." -ForegroundColor Yellow
8 | Get-CimInstance -Class Win32_UserProfile | Where-Object { ($PSItem.LocalPath | Split-Path -Leaf) -eq 'defaultuser0' } | Remove-CimInstance
9 | $ProfilePath.Refresh()
10 | If ($ProfilePath.Exists -and (Test-Path -Path $ProfilePath.FullName))
11 | {
12 | Invoke-Expression -Command ('TAKEOWN /F "{0}"' -f $ProfilePath.FullName) > $null
13 | Invoke-Expression -Command ('ICACLS "{0}" /GRANT *S-1-1-0:F' -f $ProfilePath.FullName) > $null
14 | Invoke-Expression -Command ('CMD RMDIR /S /Q "{0}"' -f $ProfilePath.FullName) > $null
15 | }
16 | }
17 | Else { Exit }
18 | }
--------------------------------------------------------------------------------
/Src/Public/Import-DataFile.ps1:
--------------------------------------------------------------------------------
1 | Function Import-DataFile
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'Image')]
4 | [OutputType([PSObject])]
5 | Param
6 | (
7 | [Parameter(ParameterSetName = 'Image',
8 | Position = 0)]
9 | [ValidateSet('Install', 'Boot', 'Recovery')]
10 | [String]$Image,
11 | [Parameter(ParameterSetName = 'CurrentVersion',
12 | Position = 0)]
13 | [Switch]$CurrentVersion,
14 | [Parameter(ParameterSetName = 'ISOMedia',
15 | Position = 0)]
16 | [Switch]$ISOMedia
17 | )
18 |
19 | Switch ($PSCmdlet.ParameterSetName)
20 | {
21 | 'Image'
22 | {
23 | If (Test-Path -Path (GetPath -Path $WorkFolder -Child ($Image + 'Info.xml'))) { Import-Clixml -Path (GetPath -Path $WorkFolder -Child ($Image + 'Info.xml')) -ErrorAction:$ErrorActionPreference }
24 | Break
25 | }
26 | 'CurrentVersion'
27 | {
28 | If (Test-Path -Path (GetPath -Path $WorkFolder -Child CurrentVersion.xml)) { Import-Clixml -Path (GetPath -Path $WorkFolder -Child CurrentVersion.xml) -ErrorAction:$ErrorActionPreference }
29 | Break
30 | }
31 | 'ISOMedia'
32 | {
33 | If (Test-Path -Path (GetPath -Path $WorkFolder -Child ISOMedia.xml)) { Import-Clixml -Path (GetPath -Path $WorkFolder -Child ISOMedia.xml) -ErrorAction:$ErrorActionPreference }
34 | Break
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Src/Public/Get-OtherWindowsPackages.ps1:
--------------------------------------------------------------------------------
1 | Function Get-OtherWindowsPackages {
2 |
3 | [CmdletBinding()]
4 |
5 | Param (
6 | [Parameter(Mandatory = $true,
7 | HelpMessage = 'full path to the root directory of the offline Windows image that you will service.')]
8 | [String]$Path,
9 | [Parameter(Mandatory = $false,
10 | HelpMessage = 'Specifies a temporary directory that will be used when extracting files for use during servicing. The directory must exist locally. If not specified, the \Windows\%Temp% directory will be used')]
11 | [String]$ScratchDirectory,
12 | [Parameter(Mandatory = $false,
13 | HelpMessage = 'the full path and file name to log to. If not set, the default is %WINDIR%\Logs\Dism\dism.log')]
14 | [String]$LogPath
15 | )
16 |
17 |
18 | return Get-WindowsPackage -Path $Path -ScratchDirectory $ScratchDirectory -LogPath $LogPath -LogLevel 1 | Where-Object { $PSItem.ReleaseType -eq 'OnDemandPack' -or $PSItem.ReleaseType -eq 'LanguagePack' -or $PSItem.ReleaseType -eq 'FeaturePack' -and $PSItem.PackageName -notlike "*20H2Enablement*" -and $PSItem.PackageName -notlike "*LanguageFeatures-Basic*" -and $PSItem.PackageName -notlike "*LanguageFeatures-TextToSpeech*" -and $PSItem.PackageState -eq 'Installed' } | Select-Object -Property PackageName, ReleaseType | Sort-Object -Property PackageName
19 | }
--------------------------------------------------------------------------------
/Upcoming.md:
--------------------------------------------------------------------------------
1 | # Upcoming Features In-Progress #
2 |
3 | This is to give a bit of information and insight as to what features are currently being implemented and tested on future versions of Optimize-Offline, what to expect and what will be getting implemented.
4 | All of these features, modules and add-ons are already either complete or going through debugging stages.
5 |
6 | * Managed WimgApi and DismApi dynamic library assemblies written in C# will replace default DISM PowerShell cmdlets (completed).
7 | * Offline update integrations (completed).
8 | * A full XML writer add-on module will allow for the creation of Answer Files (completed).
9 | * Current Windows Apps and manifests will be updatable using the Windows Store API to download those that are outdated and automatically update the package in-place (completed).
10 | * Full core component removal options and advanced imaging features (completed).
11 | * The creation of custom WinPE bootable images will be implemented (currently still in progress).
12 | * The ability to apply the image directly to a Virtual Disk or physical disk will be implemented using native Microsoft Win32 dlls (completed).
13 | * Local and network deployment compatibility (completed).
14 | * Additional runtime modules to further customize and attain full control over your system (completed).
15 |
16 | **The full GUI version is in its alpha stage to ensure complete compatibility with PowerShell 7.**
17 |
--------------------------------------------------------------------------------
/Src/Public/Get-AppxPackages.ps1:
--------------------------------------------------------------------------------
1 | Function Get-AppxPackages {
2 |
3 | [CmdletBinding()]
4 |
5 | Param (
6 | [Parameter(Mandatory = $true,
7 | HelpMessage = 'full path to the root directory of the offline Windows image that you will service.')]
8 | [String]$Path,
9 | [Parameter(Mandatory = $false,
10 | HelpMessage = 'Specifies a temporary directory that will be used when extracting files for use during servicing. The directory must exist locally. If not specified, the \Windows\%Temp% directory will be used')]
11 | [String]$ScratchDirectory,
12 | [Parameter(Mandatory = $false,
13 | HelpMessage = 'the full path and file name to log to. If not set, the default is %WINDIR%\Logs\Dism\dism.log')]
14 | [String]$LogPath
15 | )
16 |
17 | If($Global:InstallInfo.InstallationType.ToLower().Contains('server core')) {
18 | return @{}
19 | }
20 |
21 | $AppxPackages = Get-AppxProvisionedPackage -Path $Path -ScratchDirectory $ScratchDirectory -LogPath $LogPath -LogLevel 1 | Select-Object -Property DisplayName, PackageName | Sort-Object -Property DisplayName
22 |
23 | If ($Global:InstallInfo.Build -ge '19041')
24 | {
25 | $AppxPackages = $AppxPackages | ForEach-Object -Process {
26 | $DisplayName = $PSItem.DisplayName; $PackageName = $PSItem.PackageName
27 | If ($DisplayName -eq 'Microsoft.549981C3F5F10') { $DisplayName = 'CortanaApp.View.App' }
28 | [PSCustomObject]@{ DisplayName = $DisplayName; PackageName = $PackageName }
29 | }
30 | }
31 |
32 | return $AppxPackages
33 | }
--------------------------------------------------------------------------------
/Content/Additional/Setup/README.md:
--------------------------------------------------------------------------------
1 | If adding additional user content, place any setup files, scripts or content to be added to the image here.
2 |
3 | Any setup content, including answer files, scripts and executables, should ALWAYS be removed immediately after they are run by the installing Administrator unless they are designed for specific tasks when a new user account is created or logs in. Not doing so can allow other users with access to the system to run this content or extract potential sensitive data. This can be automated by adding their automatic removal to the SetupComplete.cmd that is supplied by default.
4 |
5 | The Set-Additional and Remove-OneDrive PowerShell scripts can be run by executing their associated Set-Additional.cmd and Remove-OneDrive.cmd scripts by right-clicking them and selecting 'Run as Administrator.'
6 |
7 | The Set-Additional script is supplied to only be run by users who are familiar with disabling Windows 10 default services and scheduled tasks. If you are unfamiliar with how the Set-Additional script works, or are unsure of what services and/or scheduled tasks it disables, it is strongly recommended to NOT run the script until you understand it in its entirity. The Set-Additional script does back-up the default states of all services and scheduled tasks before it processes their disabling so any can be reverted back to its default state if required. Moreover, prior to running the Set-Additional script, thoroughly inspect both the Services.json and ScheduledTasks.json files to make sure nothing is set to be disabled that will be either be required by the running system or by the end-user.
8 |
--------------------------------------------------------------------------------
/Src/GUI/XAML/ListRemovalTab.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 | {Columns}
24 |
25 |
26 |
27 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Src/Public/Test-Requirements.ps1:
--------------------------------------------------------------------------------
1 | Function Test-Requirements
2 | {
3 | If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Warning ('Elevation is required to process optimizations. Please relaunch {0} as an administrator.' -f $OptimizeOffline.BaseName); Break }
4 | If ($PSVersionTable.PSVersion.Major -lt 5) { Write-Warning ('{0} does not support PowerShell version {1}' -f $OptimizeOffline.BaseName, $PSVersionTable.PSVersion.ToString()); Break }
5 | $OSCaption = (Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty Caption)
6 | $HostEnvironment = @('Microsoft Windows', 'Microsoft Windows Server')
7 | If ($OSCaption -notlike "$($HostEnvironment[0])*" -and $OSCaption -notlike "$($HostEnvironment[1])*") { Write-Warning ('{0} requires one of the following host environments: {1}.' -f $OptimizeOffline.BaseName, ($HostEnvironment -join ', ')); Break }
8 | If ($Env:PROCESSOR_ARCHITECTURE -ne $ManifestData.ProcessorArchitecture) { Write-Warning ('{0} requires an "{1}" processor architecture.' -f $OptimizeOffline.BaseName, $ManifestData.ProcessorArchitecture); Break }
9 | If (Test-Path -Path HKLM:\SYSTEM\CurrentControlSet\Control\MiniNT) { Write-Warning ('{0} cannot be run in a Preinstallation environment.' -f $OptimizeOffline.BaseName); Break }
10 | If ((Get-UICulture).Name -ne $OptimizeOffline.Culture) { Write-Warning ('{0} is designed for the "{1}" regional culture. Not all optimizations will be available for the "{2}" regional culture.' -f $OptimizeOffline.BaseName, $OptimizeOffline.Culture, (Get-UICulture).Name); Start-Sleep 5 }
11 | }
--------------------------------------------------------------------------------
/Src/Public/Optimize-InstallMedia.ps1:
--------------------------------------------------------------------------------
1 | Function Optimize-InstallMedia
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | $ISOMedia = Import-DataFile -ISOMedia -ErrorAction:$ErrorActionPreference
7 | $InstallInfo = Import-DataFile Install -ErrorAction:$ErrorActionPreference
8 | $ISOSources = (GetPath -Path $ISOMedia.FullName -Child sources -ErrorAction:$ErrorActionPreference)
9 | @((Get-ChildItem -Path $ISOMedia.FullName -Filter *.dll), (GetPath -Path $ISOMedia.FullName -Child autorun.inf), (GetPath -Path $ISOMedia.FullName -Child setup.exe), (GetPath -Path $ISOMedia.FullName -Child ca), (GetPath -Path $ISOMedia.FullName -Child NanoServer), (GetPath -Path $ISOMedia.FullName -Child support), (GetPath -Path $ISOMedia.FullName -Child upgrade), (GetPath -Path $ISOSources -Child uup), (Get-ChildItem -Path $ISOSources -Exclude sxs -Directory | Where-Object -Property Name -NE $InstallInfo.Language)) | Purge -ErrorAction:$ErrorActionPreference
10 | @('.adml', '.mui', '.rtf', '.txt') | ForEach-Object -Process { Get-ChildItem -Path (GetPath -Path $ISOSources -Child $InstallInfo.Language) -Filter *$PSItem -Exclude setup.exe.mui -Recurse | Purge -ErrorAction SilentlyContinue }
11 | @('.dll', '.gif', '.xsl', '.bmp', '.mof', '.ini', '.cer', '.exe', '.sdb', '.txt', '.nls', '.xml', '.cat', '.inf', '.sys', '.bin', '.ait', '.admx', '.dat', '.ttf', '.cfg', '.xsd', '.rtf', '.xrm-ms') | ForEach-Object -Process { Get-ChildItem -Path $ISOSources -Filter *$PSItem -Exclude @('EI.cfg', 'gatherosstate.exe', 'setup.exe', 'lang.ini', 'pid.txt', '*.clg') -Recurse | Purge -ErrorAction:$ErrorActionPreference }
12 | If ($DynamicParams.NetFx3) { (GetPath -Path $ISOSources -Child sxs) | Purge -ErrorAction:$ErrorActionPreference }
13 | }
--------------------------------------------------------------------------------
/Src/Public/Resolve-FullPath.ps1:
--------------------------------------------------------------------------------
1 | Function Resolve-FullPath
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'None')]
4 | [OutputType([IO.FileSystemInfo])]
5 | Param
6 | (
7 | [Parameter(Mandatory = $true,
8 | ValueFromPipeline = $true,
9 | ValueFromPipelineByPropertyName = $true,
10 | Position = 0)]
11 | [Alias('FullName', 'PSPath')]
12 | [String[]]$Path,
13 | [Parameter(ParameterSetName = 'Join',
14 | Position = 1)]
15 | [String]$Child,
16 | [Parameter(ParameterSetName = 'Split',
17 | Position = 1)]
18 | [ValidateSet('Parent', 'Leaf')]
19 | [String]$Split = 'Parent'
20 | )
21 |
22 | Process
23 | {
24 | ForEach ($Item In $Path)
25 | {
26 | Try
27 | {
28 | $Item = (Resolve-Path -Path ([Environment]::ExpandEnvironmentVariables($Item)) -ErrorAction Stop).Path
29 | }
30 | Catch [Management.Automation.ItemNotFoundException]
31 | {
32 | $Item = [Environment]::ExpandEnvironmentVariables($PSItem.TargetObject)
33 | $Global:Error.RemoveAt(0)
34 | }
35 | If ($Item)
36 | {
37 | Switch ($PSCmdlet.ParameterSetName)
38 | {
39 | 'Join' { Join-Path -Path $Item -ChildPath $Child -ErrorAction:$ErrorActionPreference; Break }
40 | 'Split'
41 | {
42 | Switch ($PSBoundParameters.Split)
43 | {
44 | 'Parent' { Split-Path -Path $Item -Parent -ErrorAction:$ErrorActionPreference; Break }
45 | 'Leaf' { Split-Path -Path $Item -Leaf -ErrorAction:$ErrorActionPreference; Break }
46 | }
47 | Break
48 | }
49 | Default { $Item; Break }
50 | }
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/Src/Public/Import-RegistryTemplates.ps1:
--------------------------------------------------------------------------------
1 | Function Import-RegistryTemplates
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | Get-ChildItem -Path $OptimizeOffline.RegistryTemplates -Filter *.Offline | Purge
7 | Get-ChildItem -Path $OptimizeOffline.RegistryTemplates -Filter *.reg | ForEach-Object -Process {
8 | $REGContent = Get-Content -Path $PSItem.FullName
9 | $REGContent = $REGContent -replace 'HKEY_CLASSES_ROOT', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SOFTWARE\Classes'
10 | $REGContent = $REGContent -replace 'HKEY_LOCAL_MACHINE\\SOFTWARE', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SOFTWARE'
11 | $REGContent = $REGContent -replace 'HKEY_LOCAL_MACHINE\\SYSTEM', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SYSTEM'
12 | $REGContent = $REGContent -replace 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE\WIM_HKCU'
13 | $REGContent = $REGContent -replace 'HKEY_USERS\\.DEFAULT', 'HKEY_LOCAL_MACHINE\WIM_HKU_DEFAULT'
14 | $REGContent = $REGContent -replace 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SYSTEM\ControlSet001'
15 | $REGContent | Set-Content -Path $PSItem.FullName.Replace($PSItem.Extension, '.Offline') -Encoding Unicode -Force
16 | }
17 | If (Get-ChildItem -Path $OptimizeOffline.RegistryTemplates -Filter *.Offline)
18 | {
19 | RegHives -Load
20 | Get-ChildItem -Path $OptimizeOffline.RegistryTemplates -Filter *.Offline | ForEach-Object -Process {
21 | Try
22 | {
23 | Log ($OptimizeData.ImportingRegistryTemplate -f $PSItem.Name.Replace($PSItem.Extension, '.reg'))
24 | $RET = StartExe $REGEDIT -Arguments ('/S "{0}"' -f $PSItem.FullName)
25 | If ($RET -ne 0) { Throw }
26 | }
27 | Catch
28 | {
29 | Log ($OptimizeData.FailedImportingRegistryTemplate -f $PSItem.Name.Replace($PSItem.Extension, '.reg')) -Type Error
30 | }
31 | Finally
32 | {
33 | RegHives -Unload; Purge $PSItem.FullName; Start-Sleep 2
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Optimize-Offline.psd1:
--------------------------------------------------------------------------------
1 | <#
2 | ===========================================================================
3 | Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.194
4 | Created on: 11/20/2019 11:53 AM
5 | Created by: BenTheGreat
6 | Filename: Optimize-Offline.psd1
7 | -------------------------------------------------------------------------
8 | Module Manifest
9 | -------------------------------------------------------------------------
10 | Module Name: Optimize-Offline
11 | ===========================================================================
12 | #>
13 |
14 | @{
15 | GUID = '86c4db30-1a45-43c7-a96b-46d2a1d84671'
16 | RootModule = 'Optimize-Offline.psm1'
17 | ModuleVersion = '4.0.1.9'
18 | ModuleForkVersion = 'gdeliana-7.1'
19 | Author = 'Ben White'
20 | Copyright = '(c) 2021. All rights reserved.'
21 | Description = 'The Optimize-Offline module enables the offline optimizing of Windows images (WIM/ESD) files for optimal runtime environments.'
22 | HelpInfoUri = 'https://github.com/DrEmpiricism/Optimize-Offline/blob/master/en-US/Optimize-Offline-help.xml'
23 | PowerShellVersion = '5.1'
24 | DotNetFrameworkVersion = '4.0'
25 | CLRVersion = '4.0'
26 | ProcessorArchitecture = 'Amd64'
27 | RequiredModules = @('.\Src\Offline-Resources.psm1')
28 | ModuleList = @('.\Optimize-Offline.psm1', '.\Src\Offline-Resources.psm1')
29 | NestedModules = @('.\Src\Offline-Resources.psm1')
30 | FunctionsToExport = 'Optimize-Offline'
31 | CmdletsToExport = @()
32 | PrivateData = @{
33 | PSData = @{
34 | Tags = @('Image Optimization', 'WIM Optimization', 'Offline Windows Image', 'Offline Servicing', 'Offline Imaging', 'WIM', 'SWM', 'ESD', 'Windows 10', 'Windows 11', 'LTSC', 'Enterprise', '19H1', '19H2', '20H1', '20H2', '21H1', '21H2', 'Deployment', 'Debloat', 'DISM', 'PSModule')
35 | LicenseUri = 'https://github.com/DrEmpiricism/Optimize-Offline/blob/master/LICENSE'
36 | ProjectUri = 'https://github.com/DrEmpiricism/Optimize-Offline'
37 | ReleaseNotes = 'https://github.com/DrEmpiricism/Optimize-Offline/blob/master/ChangeLog.md'
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/Src/Private/Grant-KeyAccess.ps1:
--------------------------------------------------------------------------------
1 | Function Grant-KeyAccess
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | ValueFromPipeline = $true)]
8 | [String]$SubKey
9 | )
10 |
11 | Begin
12 | {
13 | $Access = @{
14 | FullControl = [Security.AccessControl.RegistryRights]::FullControl
15 | ContainerInherit = [Security.AccessControl.InheritanceFlags]::ContainerInherit
16 | NoPropagation = [Security.AccessControl.PropagationFlags]::None
17 | Allow = [Security.AccessControl.AccessControlType]::Allow
18 | }
19 | 'SeTakeOwnershipPrivilege' | Grant-Privilege
20 | }
21 | Process
22 | {
23 | $KeyPath = $SubKey.Insert(0, 'HKLM:\')
24 | If (Test-Path -LiteralPath $KeyPath) { $KeyOwner = [Security.Principal.NTAccount](Get-Item -LiteralPath $KeyPath -Force -ErrorAction SilentlyContinue).GetAccessControl().Owner }
25 | $Key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($SubKey, [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree, [Security.AccessControl.RegistryRights]::TakeOwnership)
26 | $ACL = $Key.GetAccessControl([Security.AccessControl.AccessControlSections]::None)
27 | $Admin = (New-Object -TypeName Security.Principal.SecurityIdentifier('S-1-5-32-544')).Translate([Security.Principal.NTAccount])
28 | $ACL.SetOwner($Admin)
29 | $Key.SetAccessControl($ACL)
30 | $ACL = $Key.GetAccessControl()
31 | $ACL.SetAccessRule((New-Object -TypeName Security.AccessControl.RegistryAccessRule($Admin, $Access.FullControl, $Access.ContainerInherit, $Access.NoPropagation, $Access.Allow)))
32 | $Key.SetAccessControl($ACL)
33 | $Key.Close()
34 | $Key.Dispose()
35 | [GC]::Collect()
36 | If ($KeyOwner -ne $Admin)
37 | {
38 | $ACL = Get-Acl -Path $KeyPath -ErrorAction SilentlyContinue
39 | $ACL.SetOwner($KeyOwner)
40 | 'SeRestorePrivilege' | Grant-Privilege
41 | $ACL | Set-Acl -Path $KeyPath -ErrorAction SilentlyContinue
42 | 'SeRestorePrivilege' | Grant-Privilege -Disable
43 | }
44 | }
45 | End
46 | {
47 | 'SeTakeOwnershipPrivilege' | Grant-Privilege -Disable
48 | }
49 | }
--------------------------------------------------------------------------------
/Configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "_Info": [
3 | "This is a JSON based Configuration file for Optimize-Offline.",
4 | "Ensure proper formatting is used when editing the JSON parameter values.",
5 | "Boolean parameter values use true and false. String parameter values must be enclosed in double-quotes.",
6 | "WindowsApps, SystemApps, Capabilities, Packages : All | None | Select | Whitelist | Blacklist",
7 | "FeaturesToEnable, FeaturesToDisable : All | None | Select | List",
8 | "Services : None | Select | List | Advanced",
9 | "CompressionType: Select | None | Fast | Maximum | Solid",
10 | "OutputPath : default | path[{filename}?] | select",
11 | "FlashToUSB: Off | UEFI | Legacy"
12 | ],
13 | "SourcePath": "PathTo:\\sources\\install.wim",
14 | "WindowsApps": "Select",
15 | "SystemApps": "Select",
16 | "Capabilities": "None",
17 | "Packages": "None",
18 | "FeaturesToEnable": "List",
19 | "FeaturesToDisable": "List",
20 | "Services": "Select",
21 | "DeveloperMode": false,
22 | "WindowsStore": false,
23 | "MicrosoftEdge": false,
24 | "Win32Calc": false,
25 | "DormantDefender": false,
26 | "Dedup": false,
27 | "DaRT": [],
28 | "Registry": false,
29 | "OutputPath": "default",
30 | "Additional": {
31 | "Setup": false,
32 | "Wallpaper": false,
33 | "SystemLogo": false,
34 | "LockScreen": false,
35 | "RegistryTemplates": false,
36 | "LayoutModification": false,
37 | "Unattend": false,
38 | "Drivers": false,
39 | "NetFx3": false
40 | },
41 | "ComponentCleanup": false,
42 | "ISO": "No-Prompt",
43 | "CompressionType": "Maximum",
44 | "SelectiveRegistry": {
45 | "DisableWindowsUpgrade": false,
46 | "DisableWindowsUpdateMicrosoft": false,
47 | "DisableDriverUpdate": false,
48 | "DormantOneDrive": false,
49 | "Disable3rdPartyApps": false,
50 | "W11ClassicContextMenu": false,
51 | "ExplorerUIRibbon": false,
52 | "ClassicSearchExplorer": false,
53 | "RemoveTaskbarPinnedIcons": false,
54 | "DisableTeamsApp": false,
55 | "DisableVirtualizationSecurity": false,
56 | "RunAsTiContextMenu": false,
57 | "AmoledBlackTheme": false
58 | },
59 | "ShutDownOnComplete": false,
60 | "FlashToUSB": "Off"
61 | }
--------------------------------------------------------------------------------
/Src/Public/Set-KeyProperty.ps1:
--------------------------------------------------------------------------------
1 | Function Set-KeyProperty
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | ValueFromPipeline = $true,
8 | ValueFromPipelineByPropertyName = $true)]
9 | [Alias('FullName', 'PSPath')]
10 | [String[]]$Path,
11 | [Parameter(Mandatory = $true)]
12 | [String]$Name,
13 | [Parameter(Mandatory = $false)]
14 | $Value,
15 | [Parameter(Mandatory = $true)]
16 | [ValidateSet('Binary', 'DWord', 'ExpandString', 'MultiString', 'QWord', 'String')]
17 | [String]$Type,
18 | [Switch]$Force
19 | )
20 |
21 | Begin
22 | {
23 | Switch ($Type)
24 | {
25 | 'Binary' { [Byte[]]$Value = $Value; Break }
26 | 'DWord' { [Int32]$Value = $Value; Break }
27 | 'ExpandString' { [String]$Value = $Value; Break }
28 | 'MultiString' { [String[]]$Value = $Value; Break }
29 | 'QWord' { [Int64]$Value = $Value; Break }
30 | 'String' { [String]$Value = $Value; Break }
31 | }
32 | $Type = [Enum]::Parse([Microsoft.Win32.RegistryValueKind], $Type, $true)
33 | If ((Get-PSDrive -PSProvider Registry).Name -notcontains 'HKLM') { $PSDrive = New-PSDrive -Name HKLM -PSProvider Registry -Root HKEY_LOCAL_MACHINE -Scope Script -ErrorAction SilentlyContinue }
34 | Push-Location -LiteralPath HKLM: -ErrorAction SilentlyContinue
35 | }
36 | Process
37 | {
38 | ForEach ($Key In $Path)
39 | {
40 | If (Test-Path -LiteralPath $Key)
41 | {
42 | If ($Force.IsPresent) { (Split-Path -Path $Key -NoQualifier).Substring(1) | Grant-KeyAccess }
43 | Set-ItemProperty -LiteralPath $Key -Name $Name -Value $Value -Type $Type -Force -ErrorAction:$ErrorActionPreference
44 | }
45 | Else
46 | {
47 | If ($Force.IsPresent -and (Test-Path -LiteralPath (Split-Path -LiteralPath $Key) -PathType Container)) { Split-Path -LiteralPath ((Split-Path -Path $Key -NoQualifier).Substring(1)) | Grant-KeyAccess }
48 | [Void](New-Item -Path $Key -ItemType Directory -Force -ErrorAction:$ErrorActionPreference | New-ItemProperty -Name $Name -Value $Value -PropertyType $Type -Force -ErrorAction:$ErrorActionPreference)
49 | }
50 | }
51 | }
52 | End
53 | {
54 | Pop-Location -ErrorAction SilentlyContinue
55 | If ($PSDrive) { Remove-PSDrive -Name $PSDrive.Name -ErrorAction SilentlyContinue }
56 | }
57 | }
--------------------------------------------------------------------------------
/Src/Private/Grant-Privilege.ps1:
--------------------------------------------------------------------------------
1 | Function Grant-Privilege
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | ValueFromPipeline = $true)]
8 | [String[]]$Privilege,
9 | [Switch]$Disable
10 | )
11 |
12 | Begin
13 | {
14 | Add-Type @'
15 | using System;
16 | using System.ComponentModel;
17 | using System.Runtime.InteropServices;
18 |
19 | public class AccessToken
20 | {
21 | [DllImport ("advapi32.dll", SetLastError = true)] static extern Boolean LookupPrivilegeValue (String Host, String Name, ref Int64 Luid);
22 | [DllImport ("advapi32.dll", ExactSpelling = true, SetLastError = true)] static extern Boolean AdjustTokenPrivileges (IntPtr TokenHandle, Boolean RevokeAllPrivileges, ref TOKEN_PRIVILEGES NewTokenState, Int32 BufferLength, IntPtr PreviousTokenState, IntPtr ReturnLength);
23 | [DllImport ("advapi32.dll", ExactSpelling = true, SetLastError = true)] static extern Boolean OpenProcessToken (IntPtr ProcessToken, Int32 DesiredAccess, ref IntPtr hObject);
24 | [DllImport ("kernel32.dll", SetLastError = true)] static extern Boolean CloseHandle (IntPtr hObject);
25 |
26 | [StructLayout (LayoutKind.Sequential, Pack = 1)] struct TOKEN_PRIVILEGES { public Int32 PrivilegeCount; public Int64 Luid; public Int32 Attributes; }
27 |
28 | internal const Int32 SE_PRIVILEGE_DISABLED = 0x00000000;
29 | internal const Int32 SE_PRIVILEGE_ENABLED = 0x00000002;
30 | internal const Int32 TOKEN_QUERY = 0x00000008;
31 | internal const Int32 TOKEN_ADJUST_PRIVILEGES = 0x00000020;
32 |
33 | public static void AdjustPrivilege (IntPtr ProcessToken, String Privilege, Boolean Enable)
34 | {
35 | var TokenHandle = IntPtr.Zero;
36 | if (!OpenProcessToken (ProcessToken, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref TokenHandle)) { throw new Win32Exception (); }
37 | try
38 | {
39 | var Privileges = new TOKEN_PRIVILEGES { PrivilegeCount = 1, Luid = 0, Attributes = Enable ? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_DISABLED, };
40 | if (!LookupPrivilegeValue (null, Privilege, ref Privileges.Luid) || !AdjustTokenPrivileges (TokenHandle, false, ref Privileges, 0, IntPtr.Zero, IntPtr.Zero)) { throw new Win32Exception (); }
41 | }
42 | finally { CloseHandle (TokenHandle); }
43 | }
44 | }
45 | '@
46 | $CurrentProcess = Get-Process -Id $PID
47 | }
48 | Process
49 | {
50 | $Privilege | ForEach-Object -Process { [AccessToken]::AdjustPrivilege($CurrentProcess.Handle, $PSItem, !$Disable.IsPresent) }
51 | }
52 | End
53 | {
54 | $CurrentProcess.Close()
55 | }
56 | }
--------------------------------------------------------------------------------
/Src/Public/DIR2ISO.ps1:
--------------------------------------------------------------------------------
1 | function :DIR2ISO ($dir, $iso, $prompt = $true, $VolumeName = 'DVD_ROM') {
2 | if (!(test-path -Path $dir -pathtype Container)) {
3 | return $false
4 | }
5 | $dir2iso = @"
6 | using System; using System.IO; using System.Runtime.Interop`Services; using System.Runtime.Interop`Services.ComTypes;
7 | public class dir2iso {public int AveYo=2021; [Dll`Import("shlwapi",CharSet=CharSet.Unicode,PreserveSig=false)]
8 | internal static extern void SHCreateStreamOnFileEx(string f,uint m,uint d,bool b,IStream r,out IStream s);
9 | public static void Create(string file, ref object obj, int bs, int tb) { IStream dir=(IStream)obj, iso;
10 | try {SHCreateStreamOnFileEx(file,0x1001,0x80,true,null,out iso);} catch(Exception e) {Console.WriteLine(e.Message); return;}
11 | int d=tb>1024 ? 1024 : 1, pad=tb%d, block=bs*d, total=(tb-pad)/d, c=total>100 ? total/100 : total, i=1, MB=(bs/1024)*tb/1024;
12 | Console.Write("{0,3}% {1}MB {2} :DIR2ISO",0,MB,file); if (pad > 0) dir.CopyTo(iso, pad * block, Int`Ptr.Zero, Int`Ptr.Zero);
13 | while (total-- > 0) {dir.CopyTo(iso, block, Int`Ptr.Zero, Int`Ptr.Zero); if (total % c == 0) {Console.Write("\r{0,3}%",i++);}}
14 | iso.Commit(0); Console.WriteLine("\r{0,3}% {1}MB {2} :DIR2ISO", 100, MB, file); } }
15 | "@; & {
16 | $cs = new-object CodeDom.Compiler.CompilerParameters
17 | $cs.GenerateInMemory = 1 #,# no`warnings
18 | $compile = (new-object Microsoft.CSharp.CSharpCodeProvider).CompileAssemblyFromSource($cs, $dir2iso)
19 | $BOOT = @()
20 | $bootable = 0
21 | $mbr_efi = @(0, 0xEF)
22 | $images = @('boot\etfsboot.com', "efi\microsoft\boot\efisys$(If (-not $prompt) {"_noprompt"}).bin")
23 |
24 | 0, 1 | % {
25 | $bootimage = join-path $dir -child $images[$_]
26 | if (test-path -Path $bootimage -pathtype Leaf) {
27 | $bin = new-object -ComObject ADODB.Stream
28 | $bin.Open()
29 | $bin.Type = 1
30 | $bin.LoadFromFile($bootimage)
31 | $opt = new-object -ComObject IMAPI2FS.BootOptions
32 | $opt.AssignBootImage($bin.psobject.BaseObject)
33 | $opt.Manufacturer = 'Microsoft'
34 | $opt.PlatformId = $mbr_efi[$_]
35 | $opt.Emulation = 0
36 | $bootable = 1
37 | $BOOT += $opt.psobject.BaseObject
38 | }
39 | }
40 |
41 | $fsi = new-object -ComObject IMAPI2FS.MsftFileSystemImage
42 | $fsi.FileSystemsToCreate = 4
43 | $fsi.FreeMediaBlocks = 0
44 | if ($bootable) {
45 | $fsi.BootImageOptionsArray = $BOOT
46 | }
47 | $CONTENT = $fsi.Root
48 | $CONTENT.AddTree($dir, $false)
49 | $fsi.VolumeName = $VolumeName
50 | $obj = $fsi.CreateResultImage()
51 | [dir2iso]::Create($iso, [ref]$obj.ImageStream, $obj.BlockSize, $obj.TotalBlocks)
52 | }
53 | [GC]::Collect()
54 | return $true
55 | } $:DIR2ISO: #,# export directory as (bootable) udf iso - lean and mean snippet by AveYo, 2021
--------------------------------------------------------------------------------
/Remove_Failure_no_prompts.cmd:
--------------------------------------------------------------------------------
1 | @setlocal DisableDelayedExpansion
2 | @echo off
3 | set _args=
4 | set _args=%*
5 | if not defined _args goto :NoProgArgs
6 | for %%A in (%_args%) do (
7 | if /i "%%A"=="-wow" set _rel1=1
8 | if /i "%%A"=="-arm" set _rel2=1
9 | )
10 | :NoProgArgs
11 | set "_cmdf=%~f0"
12 | if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
13 | setlocal EnableDelayedExpansion
14 | start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow "
15 | exit /b
16 | )
17 | if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
18 | setlocal EnableDelayedExpansion
19 | start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm "
20 | exit /b
21 | )
22 | set "_Null=1>nul 2>nul"
23 | set "SysPath=%SystemRoot%\System32"
24 | if exist "%SystemRoot%\Sysnative\reg.exe" (set "SysPath=%SystemRoot%\Sysnative")
25 | set "Path=%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
26 | reg.exe query HKU\S-1-5-19 %_Null% || (echo.&echo This script require administrator privileges.&goto :TheEnd)
27 | set _drv=%~d0
28 | set "xOS=%PROCESSOR_ARCHITECTURE%"
29 | if /i %PROCESSOR_ARCHITECTURE%==x86 (if defined PROCESSOR_ARCHITEW6432 set "xOS=%PROCESSOR_ARCHITEW6432%")
30 | set "_key=HKLM\SOFTWARE\Microsoft\WIMMount\Mounted Images"
31 | set regKeyPathFound=1
32 | set wowRegKeyPathFound=1
33 | reg.exe query "HKLM\Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots" /v KitsRoot10 %_Null% || set wowRegKeyPathFound=0
34 | reg.exe query "HKLM\Software\Microsoft\Windows Kits\Installed Roots" /v KitsRoot10 %_Null% || set regKeyPathFound=0
35 | if %wowRegKeyPathFound% equ 0 (
36 | if %regKeyPathFound% equ 0 (
37 | goto :precheck
38 | ) else (
39 | set regKeyPath=HKLM\Software\Microsoft\Windows Kits\Installed Roots
40 | )
41 | ) else (
42 | set regKeyPath=HKLM\Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots
43 | )
44 | for /f "skip=2 tokens=2*" %%i in ('reg.exe query "%regKeyPath%" /v KitsRoot10') do set "KitsRoot=%%j"
45 | set "DandIRoot=%KitsRoot%Assessment and Deployment Kit\Deployment Tools"
46 | if exist "%DandIRoot%\%xOS%\DISM\dism.exe" (
47 | set "Path=%DandIRoot%\%xOS%\DISM;%SysPath%;%SystemRoot%;%SysPath%\Wbem;%SysPath%\WindowsPowerShell\v1.0\"
48 | cd \
49 | )
50 |
51 | :precheck
52 | @cls
53 | for /f "tokens=3*" %%a in ('reg.exe query "%_key%" /s /v "Mount Path" 2^>nul ^| findstr /i /c:"Mount Path"') do (set "_mount=%%b"&call :CLN)
54 | dism.exe /English /Cleanup-Wim
55 | dism.exe /English /Cleanup-Mountpoints
56 | goto :TheEnd
57 |
58 | :CLN
59 | dism.exe /English /Image:"%_mount%" /Get-Packages %_Null%
60 | dism.exe /English /Unmount-Wim /MountDir:"%_mount%" /Discard
61 | if exist "%_mount%\" rmdir /s /q "%_mount%\" %_Null%
62 | if exist "%_mount%" (
63 | mkdir %_drv%\_del286 %_Null%
64 | robocopy %_drv%\_del286 "%_mount%" /MIR /R:1 /W:1 /NFL /NDL /NP /NJH /NJS %_Null%
65 | rmdir /s /q %_drv%\_del286\ %_Null%
66 | rmdir /s /q "%_mount%" %_Null%
67 | )
68 | exit /b
69 |
70 | :TheEnd
71 | echo.
72 | goto :eof
73 |
--------------------------------------------------------------------------------
/Src/Public/Set-LockScreen.ps1:
--------------------------------------------------------------------------------
1 | Function Set-LockScreen
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | Try
7 | {
8 | Log $OptimizeData.ApplyingLockScreen
9 | $JPGImage = Get-ChildItem -Path $OptimizeOffline.LockScreen -Filter *.jpg | Select-Object -First 1 | Copy-Item -Destination (GetPath -Path $WorkFolder -Child img100.jpg) -PassThru -Force -ErrorAction Stop
10 | $PNGImage = GetPath -Path $WorkFolder -Child ([IO.Path]::ChangeExtension($JPGImage.BaseName.Replace('100', '103'), '.png'))
11 | Add-Type -AssemblyName System.Windows.Forms, System.Drawing -ErrorAction Stop
12 | $Bitmap = New-Object System.Drawing.Bitmap($JPGImage.FullName) -ErrorAction Stop
13 | $FileStream = [IO.File]::Create($PNGImage)
14 | $Bitmap.Save($FileStream, 'png')
15 | }
16 | Catch
17 | {
18 | Log $OptimizeData.FailedApplyingLockScreen -Type Error -ErrorRecord $Error[0]
19 | Return
20 | }
21 | Finally
22 | {
23 | If ($FileStream) { $FileStream.Close(); $FileStream.Dispose() }
24 | If ($Bitmap) { $Bitmap.Dispose() }
25 | }
26 | $InstallLockScreenImage = GetPath -Path $InstallMount -Child 'Windows\Web\Screen\img100.jpg'
27 | $InstallSignOutImage = GetPath -Path $InstallMount -Child 'Windows\Web\Screen\img103.png'
28 | $WorkLockScreenImage = GetPath -Path $WorkFolder -Child img100.jpg
29 | $WorkSignOutImage = GetPath -Path $WorkFolder -Child img103.png
30 | If ((Test-Path -Path $InstallLockScreenImage) -and (Test-Path -Path $InstallSignOutImage) -and (Test-Path -Path $WorkLockScreenImage) -and (Test-Path -Path $WorkSignOutImage))
31 | {
32 | $BKPImage = Get-ChildItem -Path (GetPath -Path $InstallLockScreenImage -Split Parent) -Include img100.jpg, img103.png -Recurse -Force | ForEach-Object -Process { Copy-Item -Path $PSItem.FullName -Destination (GetPath -Path $WorkFolder -Child $PSItem.Name.Insert($PSItem.Name.Length, '.bkp')) -PassThru -Force -ErrorAction SilentlyContinue }
33 | $ACL = Get-Acl -Path $InstallLockScreenImage -ErrorAction SilentlyContinue
34 | Try
35 | {
36 | Get-ChildItem -Path (GetPath -Path $InstallLockScreenImage -Split Parent) -Include img100.jpg, img103.png -Recurse -Force | Purge -Force -ErrorAction Stop
37 | $WorkLockScreenImage, $WorkSignOutImage | Copy-Item -Destination (GetPath -Path $InstallLockScreenImage -Split Parent) -Force -ErrorAction Stop
38 | }
39 | Catch
40 | {
41 | Log $OptimizeData.FailedApplyingLockScreen -Type Error -ErrorRecord $Error[0]
42 | $BKPImage | ForEach-Object -Process { Copy-Item -Path $PSItem.FullName -Destination (GetPath -Path (GetPath -Path $InstallLockScreenImage -Split Parent) -Child $PSItem.Name.Replace('.bkp', $null)) -Force -ErrorAction SilentlyContinue }
43 | }
44 | Finally
45 | {
46 | $ACL | Set-Acl -Path $InstallLockScreenImage -Passthru -ErrorAction SilentlyContinue | Set-Acl -Path $InstallSignOutImage -ErrorAction SilentlyContinue
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/Src/GUI/XAML/Layout.xaml:
--------------------------------------------------------------------------------
1 |
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 | UEFI
37 | Legacy
38 |
39 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | {Tabs}
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Src/Public/Get-CompressionType.ps1:
--------------------------------------------------------------------------------
1 | Function Get-CompressionType
2 | {
3 | [CmdletBinding()]
4 | Param ()
5 |
6 | Begin
7 | {
8 | [Void][Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
9 | [Void][Reflection.Assembly]::LoadWithPartialName('System.Drawing')
10 | }
11 | Process
12 | {
13 | $Form = New-Object -TypeName Windows.Forms.Form -ErrorAction:$ErrorActionPreference
14 | $Form.Text = 'Compression Type'
15 | $Form.Width = 258
16 | $Form.Height = 180
17 | $Form.ShowIcon = $false
18 | $Form.TopMost = $true
19 | $Form.MaximizeBox = $false
20 | $Form.MinimizeBox = $false
21 | $Label = New-Object -TypeName Windows.Forms.Label -ErrorAction:$ErrorActionPreference
22 | $Label.Size = New-Object -TypeName Drawing.Size(185, 20) -ErrorAction:$ErrorActionPreference
23 | $Label.Text = 'Select Final Image Compression.'
24 | If ($PSVersionTable.PSVersion.Major -ge 6) { $Label.BackColor = [Drawing.Color]::Transparent; $Label.Font = [Drawing.Font]::New('Segoe UI', 9) }
25 | Else { $Label.BackColor = 'Transparent'; $Label.Font = 'Segoe UI, 9pt' }
26 | $Label.AutoSize = $false
27 | $Label.TextAlign = 'MiddleCenter'
28 | $ListBox = New-Object -TypeName Windows.Forms.ListBox -ErrorAction:$ErrorActionPreference
29 | $ListBox.Location = New-Object -TypeName Drawing.Size(10, 22) -ErrorAction:$ErrorActionPreference
30 | $ListBox.Size = New-Object -TypeName Drawing.Size(220, 20) -ErrorAction:$ErrorActionPreference
31 | $ListBox.Height = 80
32 | If ($PSVersionTable.PSVersion.Major -ge 6) { $ListBox.Font = [Drawing.Font]::New('Segoe UI', 9) }
33 | Else { $ListBox.Font = 'Segoe UI, 9pt' }
34 | ForEach ($CompressionType In @('None', 'Fast', 'Maximum', 'Solid')) { [Void]$ListBox.Items.Add($CompressionType) }
35 | $ListBox.SelectedItem = 'Fast'
36 | $OKButton = New-Object -TypeName Windows.Forms.Button -ErrorAction:$ErrorActionPreference
37 | $OKButton.Location = New-Object -TypeName Drawing.Size(10, 110) -ErrorAction:$ErrorActionPreference
38 | $OKButton.Size = New-Object -TypeName Drawing.Size(75, 23) -ErrorAction:$ErrorActionPreference
39 | $OKButton.Text = 'OK'
40 | $OKButton.DialogResult = [Windows.Forms.DialogResult]::OK
41 | $Form.AcceptButton = $OKButton
42 | [Void]$Form.Controls.Add($OKButton)
43 | [Void]$Form.Controls.Add($Label)
44 | [Void]$Form.Controls.Add($ListBox)
45 | $Form.Add_Shown{ $Form.Activate() }
46 | $InputResult = $Form.ShowDialog()
47 | If ($InputResult -eq [Windows.Forms.DialogResult]::OK) { $InputResult = $ListBox.SelectedItem }
48 | Else { $InputResult = 'Fast' }
49 | $InputResult
50 | <#
51 | While ($InputResult -eq [Windows.Forms.DialogResult]::Cancel) { $InputResult = $Form.ShowDialog() }
52 | If ($InputResult -eq [Windows.Forms.DialogResult]::OK) { $ListBox.SelectedItem }
53 | #>
54 | }
55 | End
56 | {
57 | $Form.Close()
58 | $Form.Dispose()
59 | }
60 | }
--------------------------------------------------------------------------------
/Src/Public/Get-OfflineHives.ps1:
--------------------------------------------------------------------------------
1 | Function Get-OfflineHives
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'Load')]
4 | Param
5 | (
6 | [Parameter(ParameterSetName = 'Load')]
7 | [Switch]$Load,
8 | [Parameter(ParameterSetName = 'Unload')]
9 | [Switch]$Unload
10 | )
11 |
12 | Begin
13 | {
14 | $Hive = [Ordered]@{
15 | SOFTWARE = (GetPath -Path $InstallMount -Child 'Windows\System32\Config\SOFTWARE');
16 | SYSTEM = (GetPath -Path $InstallMount -Child 'Windows\System32\Config\SYSTEM');
17 | DEFAULT = (GetPath -Path $InstallMount -Child 'Windows\System32\Config\DEFAULT');
18 | NTUSER = (GetPath -Path $InstallMount -Child 'Users\Default\NTUSER.DAT');
19 | }
20 | $HiveMountPoint = [Ordered]@{
21 | SOFTWARE = 'WIM_HKLM_SOFTWARE';
22 | SYSTEM = 'WIM_HKLM_SYSTEM';
23 | DEFAULT = 'WIM_HKU_DEFAULT';
24 | NTUSER = 'WIM_HKCU';
25 | SYSTEM_BOOT = 'BOOT_HKLM_SYSTEM';
26 | }
27 | If(Test-Path -Path (GetPath -Path $BootMount -Child 'Windows\System32\Config\SYSTEM')) {
28 | $Hive.SYSTEM_BOOT = (GetPath -Path $BootMount -Child 'Windows\System32\Config\SYSTEM')
29 | }
30 | $HKLM = 0x80000002
31 | 'SeBackupPrivilege', 'SeRestorePrivilege' | Grant-Privilege
32 | }
33 | Process
34 | {
35 | $HivesMounted = $HiveMountPoint.Values.ForEach{ If (Test-Path -LiteralPath $PSItem.Insert(0, 'HKLM:\')) { $true } }
36 | Switch ($PSCmdlet.ParameterSetName)
37 | {
38 | 'Load'
39 | {
40 | If (!$HivesMounted)
41 | {
42 | $RegLoad = Import-Win32API -Load
43 | [Void]$RegLoad::RegLoadKey($HKLM, $HiveMountPoint.SOFTWARE, $Hive.SOFTWARE)
44 | [Void]$RegLoad::RegLoadKey($HKLM, $HiveMountPoint.SYSTEM, $Hive.SYSTEM)
45 | [Void]$RegLoad::RegLoadKey($HKLM, $HiveMountPoint.DEFAULT, $Hive.DEFAULT)
46 | [Void]$RegLoad::RegLoadKey($HKLM, $HiveMountPoint.NTUSER, $Hive.NTUSER)
47 | If($Hive.SYSTEM_BOOT) {
48 | [Void]$RegLoad::RegLoadKey($HKLM, $HiveMountPoint.SYSTEM_BOOT, $Hive.SYSTEM_BOOT)
49 | }
50 | }
51 | Break
52 | }
53 | 'Unload'
54 | {
55 | If ($HivesMounted)
56 | {
57 | $RegUnload = Import-Win32API -Unload
58 | [GC]::Collect()
59 | [GC]::WaitForPendingFinalizers()
60 | $Retries = $HiveMountPoint.Values.Count + 1
61 | While ($Retries -gt 0 -and $HivesMounted)
62 | {
63 | $HiveMountPoint.Values.ForEach{ [Void]$RegUnload::RegUnLoadKey($HKLM, $PSItem) }
64 | Start-Sleep 1
65 | $HivesMounted = $HiveMountPoint.Values.ForEach{ If (Test-Path -LiteralPath $PSItem.Insert(0, 'HKLM:\')) { $true } }
66 | If ($HivesMounted) { Start-Sleep 5 }
67 | $Retries--
68 | }
69 | }
70 | Break
71 | }
72 | }
73 | }
74 | End
75 | {
76 | 'SeBackupPrivilege', 'SeRestorePrivilege' | Grant-Privilege -Disable
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Src/Public/Import-Registry.ps1:
--------------------------------------------------------------------------------
1 | Function Import-Registry
2 | {
3 | [CmdletBinding()]
4 | Param (
5 | [String]$Path,
6 | [Parameter(Mandatory=$false)]
7 | [switch]$RegistryLoaded = $false
8 | )
9 |
10 | $REGContentHandler = {
11 | param(
12 | [string]$Content
13 | )
14 | $Content = $Content -replace 'HKEY_CLASSES_ROOT', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SOFTWARE\Classes'
15 | $Content = $Content -replace 'HKEY_LOCAL_MACHINE\\SOFTWARE', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SOFTWARE'
16 | $Content = $Content -replace 'HKEY_LOCAL_MACHINE\\SYSTEM', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SYSTEM'
17 | $Content = $Content -replace 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE\WIM_HKCU'
18 | $Content = $Content -replace 'HKEY_USERS\\.DEFAULT', 'HKEY_LOCAL_MACHINE\WIM_HKU_DEFAULT'
19 | $Content = $Content -replace 'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet', 'HKEY_LOCAL_MACHINE\WIM_HKLM_SYSTEM\ControlSet001'
20 | return $Content
21 | }
22 |
23 | If(!$RegistryLoaded) {
24 | RegHives -Load
25 | }
26 |
27 |
28 | If ((Get-Item $Path) -is [System.IO.DirectoryInfo]){
29 | Get-ChildItem -Path $Path -Filter *.Offline | Purge
30 | Get-ChildItem -Path $Path -Filter *.reg | ForEach-Object -Process {
31 | $REGContent = Get-Content -Path $PSItem.FullName -Raw
32 | $REGContent = $REGContentHandler.Invoke($REGContent)
33 | $REGContent | Set-Content -Path $PSItem.FullName.Replace($PSItem.Extension, '.Offline') -Encoding Unicode -Force
34 | }
35 | If (Get-ChildItem -Path $Path -Filter *.Offline)
36 | {
37 | Get-ChildItem -Path $Path -Filter *.Offline | ForEach-Object -Process {
38 | Try
39 | {
40 | Log ($OptimizeData.ImportingRegistryTemplate -f $PSItem.Name.Replace($PSItem.Extension, '.reg'))
41 | $RET = StartExe $REGEDIT -Arguments ('/S "{0}"' -f $PSItem.FullName)
42 | If ($RET -ne 0) { Throw }
43 | }
44 | Catch
45 | {
46 | Log ($OptimizeData.FailedImportingRegistryTemplate -f $PSItem.Name.Replace($PSItem.Extension, '.reg')) -Type Error
47 | }
48 | Finally
49 | {
50 | Purge $PSItem.FullName; Start-Sleep 2
51 | }
52 | }
53 | }
54 | } Else {
55 | $RegFile = Get-Item $Path
56 | $REGContent = Get-Content -Path $RegFile.FullName -Raw
57 | $REGContent = $REGContentHandler.Invoke($REGContent)
58 | $REGContent | Set-Content -Path $RegFile.FullName.Replace($RegFile.Extension, '.Offline') -Encoding Unicode -Force
59 |
60 | $ProcessedItem = Get-Item $RegFile.FullName.Replace($RegFile.Extension, '.Offline')
61 | Try
62 | {
63 | Log ($OptimizeData.ImportingRegistryTemplate -f $ProcessedItem.Name.Replace($ProcessedItem.Extension, '.reg'))
64 | $RET = StartExe $REGEDIT -Arguments ('/S "{0}"' -f $ProcessedItem.FullName)
65 | If ($RET -ne 0) { Throw }
66 | }
67 | Catch
68 | {
69 | Log ($OptimizeData.FailedImportingRegistryTemplate -f $ProcessedItem.Name.Replace($ProcessedItem.Extension, '.reg')) -Type Error
70 | }
71 | Finally
72 | {
73 | Purge $ProcessedItem.FullName; Start-Sleep 2
74 | }
75 | }
76 |
77 | If(!$RegistryLoaded) {
78 | RegHives -Unload
79 | }
80 |
81 | }
--------------------------------------------------------------------------------
/Src/Public/Write-Log.ps1:
--------------------------------------------------------------------------------
1 | Function Write-Log
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'None')]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true,
7 | Position = 0)]
8 | [String]$Message,
9 | [ValidateSet('Info', 'Error')]
10 | [String]$Type = 'Info',
11 | [Management.Automation.ErrorRecord]$ErrorRecord,
12 | [Parameter(ParameterSetName = 'Finalized')]
13 | [Switch]$Finalized,
14 | [Parameter(ParameterSetName = 'Failed')]
15 | [Switch]$Failed,
16 | [Switch]$Quiet
17 | )
18 |
19 | Begin
20 | {
21 | [IO.FileInfo]$ModuleLog = $ModuleLog
22 | $Timestamp = (Get-Date -Format 's')
23 | $LogMutex = New-Object System.Threading.Mutex($false, "LogMutex")
24 | $Header = @"
25 | ***************************************************************************************************
26 | Running Module : $($OptimizeOffline.BaseName) $($ManifestData.ModuleVersion) $($ManifestData.ModuleForkVersion)
27 | Optimize Start : {0}
28 | Identity Name : $([Security.Principal.WindowsIdentity]::GetCurrent().Name.Split('\')[1])
29 | Computer Name : $Env:COMPUTERNAME
30 | ***************************************************************************************************
31 |
32 | "@
33 | $Footer = @"
34 |
35 | ***************************************************************************************************
36 | Optimizations Finalized : {0}
37 | ***************************************************************************************************
38 | "@
39 | [Void]$LogMutex.WaitOne()
40 | }
41 | Process
42 | {
43 | If (!$ModuleLog.Exists)
44 | {
45 | $ModuleLog = New-Item -Path $ModuleLog -ItemType File -Force
46 | $Header -f $(Get-Date -UFormat "%m/%d/%Y %r") | Out-File -FilePath $ModuleLog.FullName -Encoding UTF8 -Force
47 | }
48 | Switch ($PSBoundParameters.Type)
49 | {
50 | 'Error'
51 | {
52 | "$Timestamp [ERROR]: $Message" | Out-File -FilePath $ModuleLog.FullName -Encoding UTF8 -Append -Force
53 | If (!$Quiet.IsPresent) { $Host.UI.RawUI.WindowTitle = $Message; Write-Host $Message -ForegroundColor Red }
54 | If ($PSBoundParameters.ContainsKey('ErrorRecord') -and $null -ne $ErrorRecord)
55 | {
56 | $OptimizeErrors.Add($ErrorRecord)
57 | $ExceptionMessage = '{0} ({1}: {2}:{3} char:{4})' -f $ErrorRecord.Exception.Message, $ErrorRecord.CategoryInfo.ToString(), $ErrorRecord.InvocationInfo.ScriptName, $ErrorRecord.InvocationInfo.ScriptLineNumber, $ErrorRecord.InvocationInfo.OffsetInLine
58 | "$Timestamp [ERROR]: $ExceptionMessage" | Out-File -FilePath $ModuleLog.FullName -Encoding UTF8 -Append -Force
59 | If (!$Quiet.IsPresent) { Write-Host $ExceptionMessage -ForegroundColor Red }
60 | }
61 | Break
62 | }
63 | Default
64 | {
65 | "$Timestamp [INFO]: $Message" | Out-File -FilePath $ModuleLog.FullName -Encoding UTF8 -Append -Force
66 | If (!$Quiet.IsPresent) { $Host.UI.RawUI.WindowTitle = $Message; Write-Host $Message -ForegroundColor Cyan }
67 | Break
68 | }
69 | }
70 | Switch ($PSCmdlet.ParameterSetName)
71 | {
72 | 'Finalized'
73 | {
74 | $Footer -f $(Get-Date -UFormat "%m/%d/%Y %r") | Out-File -FilePath $ModuleLog.FullName -Encoding UTF8 -Append -Force
75 | $Host.UI.RawUI.WindowTitle = "Optimizations Completed."
76 | Break
77 | }
78 | 'Failed'
79 | {
80 | $Footer.Replace('Optimizations Finalized : {0}', 'Optimizations Failed : {0}') -f $(Get-Date -UFormat "%m/%d/%Y %r") | Out-File -FilePath $ModuleLog.FullName -Encoding UTF8 -Append -Force
81 | $Host.UI.RawUI.WindowTitle = "Optimizations Failed."
82 | Break
83 | }
84 | }
85 | }
86 | End
87 | {
88 | [Void]$LogMutex.ReleaseMutex()
89 | }
90 | }
--------------------------------------------------------------------------------
/Content/Additional/Setup/Refresh-Explorer.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Adds a method to refresh Windows objects without having to restart the Explorer process.
4 |
5 | .DESCRIPTION
6 | This method uses a Win32 API to notify the system of any events that affect the shell and then flushes the system event buffer.
7 | This method uses a Win32 API to post a message that simulates an F5 keyboard input.
8 | This method does not issue an Explorer process restart because the system event buffer is flushed in the running environment using the Win32 API.
9 | This method also refreshes system objects, like changed or modified registry keys, that normally require a system reboot.
10 | This method is useful for quickly refreshing the desktop, taskbar, icons, wallpaper, files, environmental variables and/or visual environment.
11 | #>
12 |
13 | @"
14 | Add-Type @'
15 | using System;
16 | using System.Runtime.InteropServices;
17 |
18 | namespace Win32API
19 | {
20 | public class Explorer
21 | {
22 | private static readonly IntPtr HWND_BROADCAST = new IntPtr (0xffff);
23 | private static readonly IntPtr HWND_KEYBOARD = new IntPtr (65535);
24 | private static readonly UIntPtr WM_USER = new UIntPtr (41504);
25 | private const Int32 WM_SETTINGCHANGE = 0x1a;
26 | private const Int32 SMTO_ABORTIFHUNG = 0x0002;
27 | private const Int32 VK_F5 = 273;
28 |
29 | [DllImport ("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
30 | private static extern Int32 SHChangeNotify (Int32 eventId, Int32 flags, IntPtr item1, IntPtr item2);
31 | [DllImport ("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
32 | private static extern IntPtr SendMessageTimeout (IntPtr hWnd, Int32 Msg, IntPtr wParam, String lParam, Int32 fuFlags, Int32 uTimeout, IntPtr lpdwResult);
33 | [DllImport ("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
34 | static extern bool SendNotifyMessage (IntPtr hWnd, UInt32 Msg, IntPtr wParam, String lParam);
35 | [DllImport ("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
36 | private static extern Int32 PostMessage (IntPtr hWnd, UInt32 Msg, UIntPtr wParam, IntPtr lParam);
37 |
38 | public static void RefreshEnvironment ()
39 | {
40 | SHChangeNotify (0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
41 | SendMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "Environment", SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
42 | SendNotifyMessage (HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings");
43 | }
44 |
45 | public static void RefreshShell ()
46 | {
47 | PostMessage (HWND_KEYBOARD, VK_F5, WM_USER, IntPtr.Zero);
48 | }
49 | }
50 | }
51 | '@
52 | [Win32API.Explorer]::RefreshEnvironment()
53 | [Win32API.Explorer]::RefreshShell()
54 | "@ | Out-File -FilePath "$Env:SystemRoot\Refresh-Explorer.ps1" -Encoding UTF8 -Force
55 |
56 | If (Test-Path -Path "$Env:SystemRoot\Refresh-Explorer.ps1")
57 | {
58 | New-Item -Path 'HKLM:\SOFTWARE\Classes\DesktopBackground\shell\Refresh Explorer' -ItemType Directory -Force
59 | New-Item -Path 'HKLM:\SOFTWARE\Classes\DesktopBackground\shell\Refresh Explorer\command' -ItemType Directory -Force
60 | New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\DesktopBackground\shell\Refresh Explorer' -Name 'Icon' -Value 'Explorer.exe' -PropertyType String -Force
61 | New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\DesktopBackground\shell\Refresh Explorer' -Name 'Position' -Value 'Bottom' -PropertyType String -Force
62 | New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\DesktopBackground\shell\Refresh Explorer\command' -Name '(default)' -Value "PowerShell -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File `"$Env:SystemRoot\Refresh-Explorer.ps1`"" -PropertyType String -Force
63 | }
--------------------------------------------------------------------------------
/Content/Additional/Setup/Run_TI_SetupComplete_online.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | TITLE Run SetupComplete.cmd online as TrustedInstaller
3 |
4 | :: RunAsTI (part 1 of 2) - lean and mean snippet by AveYo Source: https://github.com/AveYo/LeanAndMean
5 | whoami|findstr /i /c:"nt authority\system" >nul || ( call :RunAsTI "%~f0" %* & exit/b )
6 |
7 | pushd "%~dp0"
8 |
9 | CALL "%~dp0SetupComplete.cmd"
10 |
11 | EXIT
12 |
13 | :: RunAsTI (part 2 of 2) - lean and mean snippet by AveYo Source: https://github.com/AveYo/LeanAndMean
14 | #:RunAsTI: #1 snippet to run as TI/System, with /high priority, /priv ownership, explorer and HKCU load
15 | set ^ #=& set "0=%~f0"& set 1=%*& powershell -nop -c iex(([io.file]::ReadAllText($env:0)-split':RunAsTI\:.*')[1])& exit/b
16 | $_CAN_PASTE_DIRECTLY_IN_POWERSHELL='^,^'; function RunAsTI ($cmd) { $id='RunAsTI'; $sid=((whoami /user)-split' ')[-1]; $code=@'
17 | $ti=(whoami /groups)-like"*1-16-16384*"; $DM=[AppDomain]::CurrentDomain."DefineDynamicAss`embly"(1,1)."DefineDynamicMod`ule"(1)
18 | $D=@(); 0..5|% {$D+=$DM."DefineT`ype"("M$_",1179913,[ValueType])}; $I=[int32];$P=$I.module.gettype("System.Int`Ptr"); $U=[uintptr]
19 | $D+=$U; 4..6|% {$D+=$D[$_]."MakeB`yRefType"()};$M=$I.module.gettype("System.Runtime.Interop`Services.Mar`shal");$Z=[uintptr]::size
20 | $S=[string]; $F="kernel","advapi","advapi",($S,$S,$I,$I,$I,$I,$I,$S,$D[7],$D[8]),($U,$S,$I,$I,$D[9]),($U,$S,$I,$I,[byte[]],$I)
21 | 0..2|% {$9=$D[0]."DefinePInvokeMeth`od"(("CreateProcess","RegOpenKeyEx","RegSetValueEx")[$_],$F[$_]+'32',8214,1,$S,$F[$_+3],1,4)}
22 | $DF=0,($P,$I,$P),($I,$I,$I,$I,$P,$D[1]),($I,$S,$S,$S,$I,$I,$I,$I,$I,$I,$I,$I,[int16],[int16],$P,$P,$P,$P),($D[3],$P),($P,$P,$I,$I)
23 | 1..5|% {$k=$_;$n=1;$AveYo=1; $DF[$_]|% {$9=$D[$k]."DefineFie`ld"('f'+$n++,$_,6)}}; $T=@(); 0..5|% {$T+=$D[$_]."CreateT`ype"()}
24 | 0..5|% {nv "A$_" ([Activator]::CreateInstance($T[$_])) -force}; function F ($1,$2) {$T[0]."GetMeth`od"($1).invoke(0,$2)};
25 | if (!$ti) { $g=0; "TrustedInstaller","lsass"|% {if (!$g) {net1 start $_ 2>&1 >$null; $g=@(get-process -name $_ -ea 0|% {$_})[0]}}
26 | function M($1,$2,$3){$M."GetMeth`od"($1,[type[]]$2).invoke(0,$3)}; $H=@(); $Z,(4*$Z+16)|% {$H+=M "AllocHG`lobal" $I $_};
27 | M "WriteInt`Ptr" ($P,$P) ($H[0],$g.Handle); $A1.f1=131072;$A1.f2=$Z;$A1.f3=$H[0];$A2.f1=1;$A2.f2=1;$A2.f3=1;$A2.f4=1;$A2.f6=$A1
28 | $A3.f1=10*$Z+32;$A4.f1=$A3;$A4.f2=$H[1]; M "StructureTo`Ptr" ($D[2],$P,[boolean]) (($A2 -as $D[2]),$A4.f2,$false); $w=0x0E080600
29 | $out=@($null,"powershell -win 1 -nop -c iex `$env:A",0,0,0,$w,0,$null,($A4 -as $T[4]),($A5 -as $T[5])); F "CreateProcess" $out
30 | } else { $env:A=''; $PRIV=[uri].module.gettype("System.Diagnostics.Process")."GetMeth`ods"(42) |? {$_.Name -eq "SetPrivilege"}
31 | "SeSecurityPrivilege","SeTakeOwnershipPrivilege","SeBackupPrivilege","SeRestorePrivilege" |% {$PRIV.Invoke(0, @("$_",2))}
32 | $HKU=[uintptr][uint32]2147483651; $LNK=$HKU; $reg=@($HKU,"S-1-5-18",8,2,($LNK -as $D[9])); F "RegOpenKeyEx" $reg; $LNK=$reg[4]
33 | function SYM($1,$2){$b=[Text.Encoding]::Unicode.GetBytes("\Registry\User\$1");@($2,"SymbolicLinkValue",0,6,[byte[]]$b,$b.Length)}
34 | F "RegSetValueEx" (SYM $(($key-split'\\')[1]) $LNK); $EXP="HKLM:\Software\Classes\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}"
35 | $r="explorer"; if (!$cmd) {$cmd='C:\'}; $dir=test-path -lit ((($cmd -split '^("[^"]+")|^([^\s]+)') -ne'')[0].trim('"')) -type 1
36 | if (!$dir) {$r="start `"$id`" /high /w"}; sp $EXP RunAs '' -force; start cmd -args ("/q/x/d/r title $id && $r",$cmd) -wait -win 1
37 | do {sleep 7} while ((gwmi win32_process -filter 'name="explorer.exe"'|? {$_.getownersid().sid -eq "S-1-5-18"}))
38 | F "RegSetValueEx" (SYM ".Default" $LNK); sp $EXP RunAs "Interactive User" -force } # lean and mean snippet by AveYo, 2018-2021
39 | '@; $key="Registry::HKEY_USERS\$sid\Volatile Environment"; $a1="`$id='$id';`$key='$key';";$a2="`$cmd='$($cmd-replace"'","''")';`n"
40 | sp $key $id $($a1,$a2,$code) -type 7 -force; $arg="$a1 `$env:A=(gi `$key).getvalue(`$id)-join'';rp `$key `$id -force; iex `$env:A"
41 | $_PRESS_ENTER='^,^'; start powershell -args "-win 1 -nop -c $arg" -verb runas }; <#,#> RunAsTI $env:1; #:RunAsTI:
42 |
--------------------------------------------------------------------------------
/Src/Public/en-US/Set-RegistryProperties.strings.psd1:
--------------------------------------------------------------------------------
1 | ConvertFrom-StringData -StringData @'
2 | DisableCortana = Disabling Cortana and Search Bar Web Connectivity.
3 | DisableTelemetry = Disabling System Telemetry, Logging, Data Collecting and Advertisements.
4 | DisableTracking = Disabling Windows Tracking.
5 | DisableLocation = Disabling System Location Sensors.
6 | DisableDefaultBrowserPrompt = Disabling the Prompt to make Microsoft Edge the default browser.
7 | DisablePassReveal = Disabling the Password Reveal Button.
8 | DisableSharedExperiences = Disabling Cross-Device Sharing and Shared Experiences.
9 | DisableWiFiSense = Disabling WiFi Sense.
10 | DisableNotifications = Disabling Microsoft Toast and Lockscreen Notifications.
11 | DisableAutoplayAutorun = Disabling Connected Drive Autoplay and Autorun.
12 | DisableFileBlocking = Disabling Automatic Download File Blocking.
13 | DisableModernUISwapFile = Disabling the Modern UI Swap File.
14 | DisableReservedStorage = Disabling Reserved Storage.
15 | DisableAutoCleanup = Disabling the Automatic Clean-up of Downloads by Storage Sense.
16 | DisableLogonAnimation = Disabling the First Log-on Animation.
17 | DisableStartupSound = Disabling the Windows Start-up Sound.
18 | DisableGetMoreNotification = Disabling the Get More out of Windows Start-up Notification.
19 | EnableSearchIcon = Enabling the Search Icon on Taskbar.
20 | EnableDriveLetterBeforeDriveName = Enabling the Driver Letter before Drive Name.
21 | EnableOLEDTaskbar = Optimizing Taskbar Icons and Transparency.
22 | EnableLaunchToThisPC = Enabling File Explorer Launch to This PC.
23 | DisableJPEGQualityReduction = Disabling Wallpaper .JPEG Quality Reduction.
24 | DisableAcrylicBlur = Disabling the Sign-in Screen Acrylic Blur.
25 | DisableShortcutText = Disabling the Trailing Text for Shortcuts.
26 | EnableCMDWinXMenu = Enabling Command Prompt on the Win+X Quick Link Menu.
27 | DisableEdgeShortcutPrelaunch = Disabling Microsoft Edge Desktop Shortcut Creation and Pre-Launching.
28 | DisableTaskbarInterestsNews = Disabling Interests and News on Taskbar.
29 | DisablePinnedIcons = Disabling Pinned Windows Store, Windows Mail and People Icons.
30 | ReduceStartMenuDelay = Reducing Start Menu Delay.
31 | EnableCombineSmallIcons = Enabling TaskBar Icon Combining with Small Icons.
32 | DisableOpenFilePrompt = Disabling the Open File Prompt.
33 | EnableClassicPersonalizationPanel = Enabling the Classic Personalization Panel.
34 | EnableFloatingImmersiveControlPanel = Enabling the Floating Immersive Control Panel.
35 | EnableNewStartMenu = Enabling the 20H2 New Start Menu.
36 | EnableThisPCDesktop = Enabling This PC Desktop Icon.
37 | RemoveEditPaintPrintContextMenu = Removing Edit with Paint 3D and 3D Print from the Context Menu.
38 | RestoreWindowsPhotoViewer = Restoring Windows Photo Viewer.
39 | RemoveUserFoldersExplorer = Removing User Folders from Explorer.
40 | IncreaseIconCache = Increasing the Icon Cache Size.
41 | DisableStickyKeysPrompt = Disabling the Sticky Keys Prompt.
42 | DisableEnhancedPointerPrecision = Disabling Enhanced Pointer Precision.
43 | RemoveAccessShareCastContextMenu = Removing Give Access To, Share and Cast To Device from the Context Menu.
44 | RemoveRestorePreviousVersions = Removing Restore Previous Versions from the Context Menu.
45 | EnableRebootRecoveryMyPC = Adding Reboot to Recovery to This PC.
46 | EnableLongFilePaths = Enabling Long File Paths.
47 | EnableStrongCrypto = Enabling Strong Cryptography for .NET Applications.
48 | EnablePrintScreenKeyForSnipping = Enable Printscreen key to open snipping app
49 | '@
--------------------------------------------------------------------------------
/Content/Additional/Unattend/unattend_example.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | en-US
6 | en-US
7 | en-US
8 | en-US
9 |
10 |
11 | Eastern Standard Time
12 | ACME Inc.
13 | Anon
14 | false
15 | *
16 |
17 |
18 |
19 |
20 | http://www.google.com/favicon.ico
21 | true
22 | Google
23 | Search1
24 | http://www.google.com/search?q={searchTerms}&amp;amp;sourceid=ie7&amp;amp;rls=com.microsoft:{language}:{referrer:source}&amp;amp;ie={inputEncoding?}&amp;amp;oe={outputEncoding?}
25 | http://clients5.google.com/complete/search?q={searchTerms}&amp;client=ie8&amp;mw={ie:maxWidth}&amp;sh={ie:sectionHeight}&amp;rh={ie:rowHeight}&amp;inputencoding={inputEncoding}&amp;outputencoding={outputEncoding}
26 |
27 |
28 | yes
29 | ACME Inc.
30 | true
31 | false
32 | true
33 | true
34 | http://www.google.com
35 | false
36 |
37 |
38 |
39 |
40 | en-US
41 | en-US
42 | en-US
43 | en-US
44 |
45 |
46 |
47 | true
48 | true
49 | true
50 | true
51 | 3
52 | false
53 |
54 | false
55 | ACME Inc.
56 | Eastern Standard Time
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Content/CustomAppAssociations.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/Content/Additional/SelectiveRegistry/AMOLED_black_theme.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | ; Pitch Black Theme preset by AveYo, AccentPalette idea by /u/Egg-Tricky
4 | ; for Ctrl+Alt+Del, Logon, Taskbar, Start Menu, Action Center, Title Bar (10 & 11)
5 |
6 | [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent]
7 | [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent]
8 | "AccentColorMenu"=dword:1f000000 ; Window borders and titlebar
9 | "StartColorMenu"=dword:1f202020 ; Modals in UWP ex. Apply new refresh rate in 10
10 | "AccentPalette"=hex:\
11 | 00,9d,ff,1f,\ ; Links in action center and apps
12 | 00,9d,ff,1f,\ ; Taskbar icons underline
13 | 00,9d,ff,1f,\ ; Start button hover
14 | 00,9d,ff,1f,\ ; Settings icons and links [Blue]
15 | 00,00,00,00,\ ; Startmenu background / Active taskbar button - IF "EnableTransparency"=dword:00000000
16 | 00,00,00,00,\ ; Taskbar front and Folders on start list background [None]
17 | 00,00,00,00,\ ; Taskbar background - IF "EnableTransparency"=dword:00000001
18 | 00,00,00,00 ; Unused
19 |
20 | [-HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent]
21 | [HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent]
22 | "AccentColorMenu"=dword:1f000000 ; Window borders and titlebar
23 | "StartColorMenu"=dword:1f202020 ; Modals in UWP ex. Apply new refresh rate in 10
24 | "AccentPalette"=hex:\
25 | 00,9d,ff,1f,\ ; Links in action center and apps
26 | 00,9d,ff,1f,\ ; Taskbar icons underline
27 | 00,9d,ff,1f,\ ; Start button hover
28 | 00,9d,ff,1f,\ ; Settings icons and links [Blue]
29 | 00,00,00,00,\ ; Startmenu background / Active taskbar button - IF "EnableTransparency"=dword:00000000
30 | 00,00,00,00,\ ; Taskbar front and Folders on start list background [None]
31 | 00,00,00,00,\ ; Taskbar background - IF "EnableTransparency"=dword:00000001
32 | 00,00,00,00 ; Unused
33 |
34 | [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]
35 | [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]
36 | "ColorPrevalence"=dword:00000001 ; Show accent color on Title bars and window borders [x]
37 | "AccentColor"=dword:1f000000 ; Active title bars - black unsupported in the UI but works with AccentPalette
38 | "AccentColorInactive"=dword:1f202020 ; Inactive title bars
39 |
40 | [-HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\DWM]
41 | [HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\DWM]
42 | "ColorPrevalence"=dword:00000001 ; Show accent color on Title bars and window borders [x]
43 | "AccentColor"=dword:1f000000 ; Active title bars - black unsupported in the UI but works with AccentPalette
44 | "AccentColorInactive"=dword:1f202020 ; Inactive title bars
45 |
46 | [-HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]
47 | [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]
48 | "ColorPrevalence"=dword:00000001 ; Show accent color on Start, taskbar and action center [x]
49 | "AppsUseLightTheme"=dword:00000000 ; Apps mode [Dark]
50 | "SystemUsesLightTheme"=dword:00000000 ; Windows mode [Dark]
51 | "EnabledBlurBehind"=dword:00000001 ; Blur [x]
52 | "EnableTransparency"=dword:00000000 ; Transparency []
53 |
54 | [-HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]
55 | [HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]
56 | "ColorPrevalence"=dword:00000001 ; Show accent color on Start, taskbar and action center [x]
57 | "AppsUseLightTheme"=dword:00000000 ; Apps mode [Dark]
58 | "SystemUsesLightTheme"=dword:00000000 ; Windows mode [Dark]
59 | "EnabledBlurBehind"=dword:00000001 ; Blur [x]
60 | "EnableTransparency"=dword:00000000 ; Transparency []
61 |
62 | [-HKEY_CURRENT_USER\Control Panel\Colors]
63 | [HKEY_CURRENT_USER\Control Panel\Colors]
64 | "Hilight"="0 157 255" ; [Blue]
65 | "HotTrackingColor"="0 157 255"
66 | "MenuHilight"="0 157 255"
67 |
68 | [-HKEY_USERS\.DEFAULT\Control Panel\Colors]
69 | [HKEY_USERS\.DEFAULT\Control Panel\Colors]
70 | "Hilight"="0 157 255" ; [Blue]
71 | "HotTrackingColor"="0 157 255"
72 | "MenuHilight"="0 157 255"
73 |
74 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
75 | "Background"="0 0 0"
76 |
77 | [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System]
78 | "DisableAcrylicBackgroundOnLogon"=dword:00000001 ; AveYo: enable pure black logon on 11
79 | "DisableLogonBackgroundImage"=dword:00000001 ; enable solid color logon - separate undo.reg provided
80 |
81 | [HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Personalization]
82 | "PersonalColors_Background"="#000000" ; AveYo: this is what was missing to make Ctrl+Alt+Del background black as well
83 | "PersonalColors_Accent"=-
84 | "NoLockScreen"=dword:00000001 ; no lock screen entirely - separate undo.reg provided
85 |
86 | [-HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DWM]
87 | ; done - log off and back on to see all changes
--------------------------------------------------------------------------------
/Src/Public/New-ISOMedia.ps1:
--------------------------------------------------------------------------------
1 | Function New-ISOMedia
2 | {
3 | [CmdletBinding()]
4 | Param
5 | (
6 | [Parameter(Mandatory = $true)]
7 | [ValidateSet('Prompt', 'No-Prompt')]
8 | [String]$BootType
9 | )
10 | Begin {
11 | $ISOMedia = Import-DataFile -ISOMedia -ErrorAction:$ErrorActionPreference
12 | $InstallInfo = Import-DataFile Install -ErrorAction:$ErrorActionPreference
13 | $ISOFile = GetPath -Path $WorkFolder -Child ($($InstallInfo.Edition).Replace(' ', '') + "_$($InstallInfo.Build).iso")
14 |
15 | $BootFile = Switch ($BootType)
16 | {
17 | 'Prompt' { 'efisys.bin'; Break }
18 | 'No-Prompt' { 'efisys_noprompt.bin'; Break }
19 | }
20 | If ($PSVersionTable.PSVersion.Major -gt 5 -and !(Test-Path -Path (GetPath -Path $ISOMedia.FullName -Child 'boot\etfsboot.com'))) { Log "Missing the required etfsboot.com bootfile for ISO creation." -Type Error; Start-Sleep 3; Break }
21 | If (!(Test-Path -Path (GetPath -Path $ISOMedia.FullName -Child "efi\Microsoft\boot\$($BootFile)"))) { Log ('Missing the required {0} bootfile for ISO creation.' -f $BootFile) -Type Error; Start-Sleep 3; Break }
22 | If (!('ISOWriter' -as [Type]))
23 | {
24 | Add-Type -TypeDefinition @'
25 | using System;
26 | using System.IO;
27 | using System.Runtime.InteropServices;
28 | using System.Runtime.InteropServices.ComTypes;
29 |
30 | public class ISOWriter
31 | {
32 | [DllImport ("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false, EntryPoint = "SHCreateStreamOnFileEx")]
33 | internal static extern void SHCreateStreamOnFileEx (String FileName, UInt32 Mode, UInt32 Attributes, Boolean Create, IStream StreamNull, out IStream Stream);
34 |
35 | public static void Create (String FilePath, ref Object ImageStream, Int32 BlockSize, Int32 TotalBlocks)
36 | {
37 | IStream ResultStream = (IStream) ImageStream, ImageFile;
38 | SHCreateStreamOnFileEx (FilePath, 0x1001, 0x80, true, null, out ImageFile);
39 | Int32 Data = TotalBlocks > 1024 ? 1024 : 1;
40 | Int32 Pointer = TotalBlocks % Data;
41 | Int32 SizeBytes = BlockSize * Data;
42 | Int32 Buffer = (TotalBlocks - Pointer) / Data;
43 | if (Pointer > 0)
44 | ResultStream.CopyTo (ImageFile, Pointer * SizeBytes, IntPtr.Zero, IntPtr.Zero);
45 | while (Buffer-- > 0)
46 | {
47 | ResultStream.CopyTo (ImageFile, SizeBytes, IntPtr.Zero, IntPtr.Zero);
48 | }
49 | ImageFile.Commit (0);
50 | }
51 | }
52 | '@
53 | }
54 | $BootOptionsDetail = @(
55 | @{
56 | File = (Get-ChildItem -Path "$($ISOMedia.FullName)\boot\etfsboot.com" | Select-Object -ExpandProperty FullName)
57 | PlatformId = 0
58 | },
59 | @{
60 | File = (Get-ChildItem -Path "$($ISOMedia.FullName)\efi\Microsoft\boot" -Filter $BootFile | Select-Object -ExpandProperty FullName)
61 | PlatformId = 0xEF
62 | }
63 | )
64 | $BootOptions = @()
65 | Foreach($BootOptionDetail in $BootOptionsDetail)
66 | {
67 | ($BootStream = New-Object -ComObject ADODB.Stream -Property @{ Type = 1 } -ErrorAction:$ErrorActionPreference).Open()
68 | $BootStream.LoadFromFile($BootOptionDetail.File)
69 | $BootOption = New-Object -ComObject IMAPI2FS.BootOptions -Property @{ PlatformId = $BootOptionDetail.PlatformId; Manufacturer = 'Microsoft'; Emulation = 0 } -ErrorAction:$ErrorActionPreference
70 | $BootOption.AssignBootImage($BootStream.psobject.BaseObject)
71 | $BootOptions += $BootOption.psobject.BaseObject
72 | }
73 | $FileSystem = @{ UDF = 4 };
74 | $FSImage = New-Object -ComObject IMAPI2FS.MsftFileSystemImage -Property @{ FileSystemsToCreate = $FileSystem.UDF; UDFRevision = 0x102; FreeMediaBlocks = 0; VolumeName = $InstallInfo.Name; WorkingDirectory = $WorkFolder } -ErrorAction:$ErrorActionPreference
75 | }
76 | Process
77 | {
78 | $FSImage.Root.AddTree($ISOMedia.FullName, $false)
79 | }
80 | End
81 | {
82 | $FSImage.BootImageOptionsArray = $BootOptions
83 | $WriteISO = $FSImage.CreateResultImage()
84 | $ISOFile = New-Item -Path $WorkFolder -Name ($($InstallInfo.Edition).Replace(' ', '') + "_$($InstallInfo.Build).iso") -ItemType File -Force -ErrorAction:$ErrorActionPreference
85 | If ($ISOFile.Exists)
86 | {
87 | [ISOWriter]::Create($ISOFile.FullName, [ref]$WriteISO.ImageStream, $WriteISO.BlockSize, $WriteISO.TotalBlocks)
88 | $ISOFile.Refresh()
89 | If (($WriteISO.BlockSize * $WriteISO.TotalBlocks) -eq $ISOFile.Length) { $ISOFile.FullName }
90 | }
91 | While ([Runtime.Interopservices.Marshal]::ReleaseComObject($BootStream) -gt 0) { }
92 | Foreach($BootOption in $BootOptions){
93 | While ([Runtime.Interopservices.Marshal]::ReleaseComObject($BootOption) -gt 0) { }
94 | }
95 | While ([Runtime.Interopservices.Marshal]::ReleaseComObject($FSImage) -gt 0) { }
96 | While ([Runtime.Interopservices.Marshal]::ReleaseComObject($WriteISO) -gt 0) { }
97 | [GC]::Collect()
98 | [GC]::WaitForPendingFinalizers()
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/ChangeLog.md:
--------------------------------------------------------------------------------
1 | # ChangeLog #
2 |
3 | ## Build 4.0.1.10 (02-16-2023) ##
4 |
5 | - Corrected the improper formatting of the output WimFileInfo.xml file when running Optimize-Offline with PowerShell 7+
6 | - Windows 10 22H2 will now display properly in the output WimFileInfo.xml file.
7 | - Added additional telemetry disabling registry entries.
8 | - Disabled Interests and News and Meet Now taskbar registry entries.
9 | - Updated the Win32Calc integration WIM file.
10 | - Updated the integrated Microsoft Edge Administrative Policy Templates WIM file to the latest versions.
11 | - Updated the integrated CustomAppsAssociations.xml
12 | - Updated the 'Additional Tweaks' registry template.
13 | - Updated the Set-Additional.ps1 post-setup script.
14 | - Added a Remove-DefaultUser0.ps1 post-setup script.
15 | - The Get-DeploymentTool function has been replaced with the Get-DISMPath function.
16 | - Removed redundancies in the Invoke-Cleanup function.
17 | - Additional framework code changes and other core module updates.
18 |
19 | **NOTE: Windows 11 compatibility will be coming with build 4.0.2. Furthermore, the reason for the fairly long hiatus with updates has been due to the passing of my father and the subsequent birth of a little bundle of joy. Though my personal life is not anyone's business on the internet, I also do not think it's fair to let those who use this framework to sit in the dark about its current state. Conclusively, I will try to get to the Troubleshooting/Bug reports as soon as I'm available to do so. Thank you for your understanding and patience.**
20 |
21 | ## Build 4.0.1.9 (09-12-2021) ##
22 |
23 | - Optimize-Offline's native ISO creation function has been re-written and now supports PowerShell 6+.
24 | - The names of the Biometric FOD packages that are automatically removed when the BioEnrollment System Application has been removed are now displayed and logged.
25 | - Added the disabling of Windows Taskbar Interests and News.
26 | - Additional framework code changes and other core module updates.
27 |
28 | **NOTE: A very small update was added on 09-16-2021 that adds 21H2 to the Get-ImageData function as well as the module manifest.**
29 |
30 | ## Build 4.0.1.8 (06-22-2021) ##
31 |
32 | **NOTE: Updates should resume with the same frequency as before.**
33 |
34 | - Optimize-Offline now supports Windows 10 build 19043 (21H1)
35 | - When it is detected that the BioEnrollment System Application has been removed, Optimize-Offline will not automatically remove its associated Capability Packages.
36 | - A -ComponentCleanup switch has been added that will compress all superseded components, thus reducing the size of the Component Store.
37 | - The DaRT 20H1/21H1 WIM file has been updated.
38 | - External help files have been updates.
39 | - Additional framework code changes to support Windows 10 21H1 and other core module updates.
40 |
41 | ## Build 4.0.1.7 (11-13-2020 and 12-11-2020) ##
42 |
43 | - Optimize-Offline now supports PowerShell Core 7.
44 | - Updated required Resource Functions for PowerShell Core 7 compatibility.
45 | - Updated the Start-Optimize call script for PowerShell Core 7 compatibility.
46 | - Corrected a non-terminating error that could occur for a null value when no DaRT parameters were passed when processing the boot.wim and/or winre.wim.
47 | - Added the Deduplication integration packages for Windows 10 builds 19041+. **added 12-11-2020**
48 | - Updated the Edge Chromium integration package for Windows 10 builds 19041+.
49 | - Updated the Edge Chromium integration process.
50 | - Updated the Windows Store bundle packages.
51 | - If the removal of System Applications returns an error, it will now continue to the next System Application selected in the Gridview list instead of returning to the caller scope.
52 | - Added the 20H2 Enablement package to the exclusion list when outputting a Gridview list of Windows Cabinet Packages available for removal.
53 | - The Windows Cabinet Packages are now output to its Gridview list sorted in order by their package names instead of package type. This way all packages for a specific feature are in order to make selecting all of them easier without potentially skipping one.
54 | - Improved the exported package log formatting.
55 |
56 | **Note: If creating bootable ISO media using PowerShell Core 7, Optimize-Offline must be able to resolve the path to the oscdimg.exe premastering tool included in the Windows 10 ADK, as its default API function wrapper contains code that is not yet fully supported by PowerShell versions higher than 5.**
57 |
58 | ## Build 4.0.1.6 (10-06-2020) ##
59 |
60 | - Added support for the SWM (split Windows image) file type.
61 | - If the source image is a SWM file, only the first SWM file needs passed to Optimize-Offline. It will recursively copy all additional SWM files. Likewise, the SWM files do not need to be named 'install.swm,' etc. Do note that in order to use a SWM file as the source image, all of the SWM files must be in their own directory. For example, if there are three SWM files named 'test.swm,' 'test2.swm,' 'test3.swm,' then all three of these SWM files must be in their own directory in order for Optimize-Offline to recognize them as split images from the same WIM file.
62 | - Corrected some registry vales that contained an invalid hive mount point.
63 | - Updated the Microsoft Edge Chromium package for Windows 10 builds 19041+.
64 | - Updated the Windows Store bundle packages.
65 | - The MAML XML external help file and manifest data have been updated.
66 | - Multiple code improvements across the framework.
67 |
--------------------------------------------------------------------------------
/Src/Public/Write-USB.ps1:
--------------------------------------------------------------------------------
1 |
2 | Function Update_bcd
3 | {
4 | param ($usbpartition)
5 | & bcdedit /store "$usbpartition\boot\bcd" /set '{default}' bootmenupolicy Legacy | Out-Null
6 | & bcdedit /store "$usbpartition\EFI\Microsoft\boot\bcd" /set '{default}' bootmenupolicy Legacy |Out-Null
7 | Set-ItemProperty -Path "$usbpartition\boot\bcd" -Name IsReadOnly -Value $true
8 | Set-ItemProperty -Path "$usbpartition\EFI\Microsoft\boot\bcd" -Name IsReadOnly -Value $true
9 | }
10 | Function Write-USB {
11 |
12 | [CmdletBinding()]
13 |
14 | Param (
15 | [Parameter(
16 | Mandatory = $true,
17 | HelpMessage = 'full path of the source files to be flashed to the usb device'
18 | )]
19 | [String]$Source,
20 | [Parameter(
21 | Mandatory = $true,
22 | HelpMessage = 'USB device drive object'
23 | )]
24 | [PSCustomObject]$USBDrive,
25 | [Parameter(
26 | Mandatory = $false,
27 | HelpMessage = 'USB label'
28 | )]
29 | [String]$Label = "Windows_Install",
30 | [Parameter(
31 | Mandatory = $false,
32 | HelpMessage = "If usb will support legacy bios booting scheme"
33 | )]
34 | [Switch]$Legacy = $false,
35 | [Parameter(
36 | Mandatory = $false,
37 | HelpMessage = "Will override the main USB partition FS type to this one"
38 | )]
39 | [ValidateSet("NTFS", "FAT32")]
40 | [String]$ForceFS,
41 | [Parameter(
42 | Mandatory = $false,
43 | HelpMessage = "Will override the main USB partition schema to this one"
44 | )]
45 | [ValidateSet("MBR", "GPT")]
46 | [String]$ForcePartitionSchema
47 | )
48 |
49 | Try {
50 | If ($USBDrive.Count -eq 0 -or $USBDrive.BusType -ne "USB") {
51 | Throw "Could not find USB drive"
52 | }
53 | $TotalSize = (Get-PathSize -Path $Source)
54 | $USBSize = $USBDrive.Size
55 | If ($USBSize -lt $TotalSize + 100MB) {
56 | Throw "USB disk size is smaller than ISO size"
57 | }
58 | $PartitionSchema = $(If($ForcePartitionSchema) {$ForcePartitionSchema} Else {"MBR"})
59 | $FileSystem = $(If ($ForceFS) {$ForceFS} Else {If($Legacy) {"FAT32"} Else {"NTFS"}})
60 | @"
61 | select disk $($USBDrive.DiskNumber)
62 | clean
63 | convert $PartitionSchema
64 | rescan
65 | exit
66 | "@ | diskpart | Out-Null
67 |
68 | Stop-Service ShellHWDetection -ErrorAction SilentlyContinue | Out-Null
69 |
70 | If(!$Legacy){
71 |
72 | $bootSize = (Get-PathSize -Path "$Source\bootmgr*")
73 | $bootSize += (Get-PathSize -Path "$Source\boot")
74 | $bootSize += (Get-PathSize -Path "$Source\efi")
75 | $bootSize += (Get-PathSize -Path "$Source\sources\boot.wim")
76 |
77 | If($bootSize -eq 0) {
78 | Throw "Boot files total size is 0"
79 | }
80 |
81 | $bootSize += 100MB
82 |
83 | If($bootSize -gt $USBSize) {
84 | Throw "Boot files total size is greater than usb size"
85 | }
86 |
87 | $USBUEFIVolume = $USBDrive |
88 | New-Partition -Size $bootSize -AssignDriveLetter |
89 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel "BOOT"
90 |
91 | Copy-Item -Path "$Source\bootmgr*" -Destination "$($USBUEFIVolume.DriveLetter):\"
92 | Copy-Item -Path "$Source\boot" -Destination "$($USBUEFIVolume.DriveLetter):\boot" -Recurse
93 | Copy-Item -Path "$Source\efi" -Destination "$($USBUEFIVolume.DriveLetter):\efi" -Recurse
94 | If (!(Test-Path -path "$($USBUEFIVolume.DriveLetter):\sources")) {
95 | New-Item "$($USBUEFIVolume.DriveLetter):\sources" -Type Directory | Out-Null
96 | }
97 | Copy-Item -Path "$Source\sources\boot.wim" -Destination "$($USBUEFIVolume.DriveLetter):\sources"
98 |
99 | Update_bcd $($USBUEFIVolume.DriveLetter+":")
100 |
101 | $USBSize -= $bootSize
102 |
103 | }
104 | $NewPartitionParams = @{
105 | AssignDriveLetter = $true
106 | ErrorAction = "Stop"
107 | }
108 | If($PartitionSchema -eq "MBR") {
109 | $NewPartitionParams.IsActive = $true
110 | }
111 | If ($FileSystem -eq "FAT32" -and $USBSize -gt 32GB) {
112 | $NewPartitionParams.Size = 32GB
113 | } Else {
114 | $NewPartitionParams.UseMaximumSize = $true
115 | }
116 | $USBVolume = $USBDrive |
117 | New-Partition @NewPartitionParams |
118 | Format-Volume -FileSystem $FileSystem -ErrorAction Stop -NewFileSystemLabel $Label
119 |
120 | $CopyItemParams = @{
121 | Path = "$Source\*"
122 | Destination = "$($USBVolume.DriveLetter):"
123 | Recurse = $true
124 | Force = $true
125 | ErrorAction = "Stop"
126 | Exclude = @()
127 | }
128 |
129 | If (!$Legacy) {
130 | $CopyItemParams.Exclude = $CopyItemParams.Exclude + "boot.wim"
131 | }
132 |
133 | If ($FileSystem -eq "FAT32" -and (Test-Path -Path "$Source\sources\install.wim") -and (Get-Item -Path "$Source\sources\install.wim").Length -gt 4GB) {
134 | [Void](New-Item -Path "$($USBVolume.DriveLetter):\sources" -Type Directory)
135 | [Void](Split-WindowsImage -ImagePath "$Source\sources\install.wim" -SplitImagePath "$($USBVolume.DriveLetter):\sources\install.swm" -FileSize 4090 -LogPath $DISMLog -ScratchDirectory $ScratchFolder -LogLevel 1 -ErrorAction Stop)
136 | $CopyItemParams.Exclude = $CopyItemParams.Exclude + "install.wim"
137 | }
138 | Copy-Item @CopyItemParams
139 |
140 | If(!$Legacy){
141 | Update_bcd $($USBVolume.DriveLetter+":")
142 | } Else {
143 | [Void](& "$Source\boot\bootsect.exe" /nt60 "$($USBVolume.DriveLetter):")
144 | }
145 | } Catch {
146 | Throw $Error[0]
147 | } Finally {
148 | Start-Service ShellHWDetection -ErrorAction SilentlyContinue | Out-Null
149 | If (!$Legacy -and $USBUEFIVolume) {
150 | @"
151 | select volume $($USBUEFIVolume.DriveLetter)
152 | remove letter=$($USBUEFIVolume.DriveLetter)
153 | rescan
154 | exit
155 | "@ | diskpart | Out-Null
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/Start-Optimize.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Start-Optimize is a configuration call script for the Optimize-Offline module.
4 |
5 | .DESCRIPTION
6 | Start-Optimize automatically imports the configuration JSON file into the Optimize-Offline module.
7 |
8 | .EXAMPLE
9 | .\Start-Optimize.ps1
10 |
11 | This command will import all values set in the configuration JSON file into the Optimize-Offline module and begin the optimization process.
12 |
13 | .NOTES
14 | Start-Optimize requires that the configuration JSON file is present in the root path of the Optimize-Offline module.
15 | #>
16 | [CmdletBinding()]
17 | Param (
18 | [Parameter(Mandatory = $false)] [switch]$populateLists,
19 | [Parameter(Mandatory = $false)] [switch]$populateTemplates,
20 | [Parameter(Mandatory = $false)] [switch]$GUI,
21 | [Parameter(Mandatory = $false)] [int]$FlashUSBDriveNumber = -1
22 | )
23 |
24 | $Global:Error.Clear()
25 |
26 | # Ensure we are running with administrative permissions.
27 | If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
28 | $arguments = @(" Set-ExecutionPolicy Bypass -Scope Process -Force; & '" + $MyInvocation.MyCommand.Definition + "'")
29 | foreach ($param in $PSBoundParameters.GetEnumerator()) {
30 | $arguments += "-"+[string]$param.Key+$(If ($null -ne $param.Value -and $param.Value -ne "" -and $param.Value -notin @("True", "False")) {" '"+$param.Value+"'"} Else {""})
31 | }
32 | If(!$GUI){
33 | $arguments += " ; pause"
34 | }
35 | Start-Process powershell -Verb RunAs -ArgumentList $arguments
36 | Stop-Process -Id $PID
37 | }
38 |
39 | $configration_selected = "Configuration.json"
40 |
41 | If (Test-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath "Configuration_custom.json")) {
42 | $configration_selected = "Configuration_custom.json"
43 | }
44 |
45 | # Ensure the configuration JSON file exists.
46 | If (!(Test-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath $configration_selected))) {
47 | Write-Warning ('The required configuration JSON file does not exist: "{0}"' -f (Join-Path -Path $PSScriptRoot -ChildPath $configration_selected))
48 | Start-Sleep 3
49 | Exit
50 | }
51 |
52 | # If the configuration JSON or ordered collection list variables still exists from a previous session, remove them.
53 | If ((Test-Path -Path Variable:\ContentJSON) -or (Test-Path -Path Variable:\ConfigParams)) {
54 | Remove-Variable -Name ContentJSON, ConfigParams -ErrorAction Ignore
55 | }
56 |
57 | # Use a Try/Catch/Finally block in case the configuration JSON file URL formatting is invalid so we can catch it, correct its formatting and continue.
58 | Try {
59 | $ContentJSON = Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath $configration_selected) -Raw | ConvertFrom-Json
60 | }
61 | Catch [ArgumentException] {
62 | $ContentJSON = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath $configration_selected) -Raw).Replace('\', '\\') | Set-Content -Path (Join-Path -Path $Env:TEMP -ChildPath $configration_selected) -Encoding UTF8 -Force -PassThru
63 | $ContentJSON = $ContentJSON | ConvertFrom-Json
64 | Move-Item -Path (Join-Path -Path $Env:TEMP -ChildPath $configration_selected) -Destination $PSScriptRoot -Force
65 | $Global:Error.Remove($Error[-1])
66 | }
67 | Finally {
68 | $ContentJSON.PSObject.Properties.Remove('_Info')
69 | }
70 |
71 | # Convert the JSON object into a nested ordered collection list. We use the PSObject.Properties method to retain the JSON object order.
72 | $ConfigParams = [Ordered]@{ }
73 | ForEach ($Name In $ContentJSON.PSObject.Properties.Name) {
74 | $Value = $ContentJSON.PSObject.Properties.Item($Name).Value
75 | If ($Value -is [PSCustomObject]) {
76 | $ConfigParams.$Name = [Ordered]@{ }
77 | ForEach ($Property in $Value.PSObject.Properties) {
78 | $ConfigParams.$Name[$Property.Name] = $Property.Value
79 | }
80 | }
81 | Else {
82 | $ConfigParams.$Name = $Value
83 | }
84 | }
85 | $ConfigParams.populateLists = $populateLists
86 | $ConfigParams.populateTemplates = $populateTemplates
87 |
88 | If ($FlashUSBDriveNumber -ge 0){
89 | $ConfigParams.FlashUSBDriveNumber = $FlashUSBDriveNumber
90 | }
91 |
92 | # Import the Optimize-Offline module and call it by passing the JSON configuration.
93 | If ($PSVersionTable.PSVersion.Major -gt 5) {
94 | Try {
95 | Import-Module Dism -SkipEditionCheck -Force -WarningAction Ignore -ErrorAction Stop
96 | }
97 | Catch {
98 | Write-Warning 'Failed to import the required Dism module.'
99 | Start-Sleep 3
100 | Exit
101 | }
102 | Try {
103 | Import-Module (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1) -SkipEditionCheck -Force -WarningAction Ignore -ErrorAction Stop
104 | }
105 | Catch {
106 | Write-Warning ('Failed to import the Optimize-Offline module: "{0}"' -f (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1))
107 | Start-Sleep 3
108 | Exit
109 | }
110 | }
111 | Else {
112 | Try {
113 | Import-Module (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1) -Force -WarningAction Ignore -ErrorAction Stop
114 | }
115 | Catch {
116 | Write-Warning ('Failed to import the Optimize-Offline module: "{0}"' -f (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1))
117 | Start-Sleep 3
118 | Exit
119 | }
120 | }
121 |
122 | If ($GUI){
123 | Try{
124 | Optimize-Offline @ConfigParams
125 | } Catch {
126 | $formatstring = "{0} : {1}`n{2}`n" +
127 | " + CategoryInfo : {3}`n" +
128 | " + FullyQualifiedErrorId : {4}`n"
129 | $fields = $_.InvocationInfo.MyCommand.Name,
130 | $_.ErrorDetails.Message,
131 | $_.InvocationInfo.PositionMessage,
132 | $_.CategoryInfo.ToString(),
133 | $_.FullyQualifiedErrorId
134 | Write-Host -Foreground Red ($formatstring -f $fields)
135 | Exit
136 | }
137 | } Else {
138 | Optimize-Offline @ConfigParams
139 | }
140 |
--------------------------------------------------------------------------------
/Src/Public/Get-ImageData.ps1:
--------------------------------------------------------------------------------
1 | Function Get-ImageData
2 | {
3 | [CmdletBinding(DefaultParameterSetName = 'ImageData')]
4 | [OutputType([PSCustomObject])]
5 | Param
6 | (
7 | [Parameter(ParameterSetName = 'ImageData',
8 | Mandatory = $true,
9 | ValueFromPipeline = $true,
10 | Position = 0)]
11 | [IO.FileInfo]$ImageFile,
12 | [Parameter(ParameterSetName = 'ImageData',
13 | Mandatory = $false,
14 | Position = 1)]
15 | [Int]$Index = 1,
16 | [Parameter(ParameterSetName = 'Update')]
17 | [Switch]$Update
18 | )
19 |
20 | Process
21 | {
22 | Switch ($PSCmdlet.ParameterSetName)
23 | {
24 | 'ImageData'
25 | {
26 | $ArchString = @{ [UInt32]0 = 'x86'; [UInt32]5 = 'arm'; [UInt32]6 = 'ia64'; [UInt32]9 = 'amd64'; [UInt32]12 = 'arm64' }
27 | $ImageDataFile = $ImageFile.BaseName.Replace($ImageFile.BaseName[0], $ImageFile.BaseName[0].ToString().ToUpper()).Insert($ImageFile.BaseName.Length, 'Info.xml')
28 | $ImageInfo = (Get-WindowsImage -ImagePath $ImageFile.FullName -Index $Index -ScratchDirectory $ScratchFolder -LogPath $DISMLog -LogLevel 1 -ErrorAction:$ErrorActionPreference)
29 | $ImageData = [PSCustomObject][Ordered]@{
30 | Path = $ImageInfo.ImagePath
31 | Index = $ImageInfo.ImageIndex
32 | Name = $ImageInfo.ImageName
33 | Description = $ImageInfo.ImageDescription
34 | Size = '{0:N2} GB' -f ($ImageInfo.ImageSize / 1GB)
35 | Edition = $ImageInfo.EditionID
36 | VersionTable = [PSCustomObject][Ordered]@{ Major = $ImageInfo.MajorVersion; Minor = $ImageInfo.MinorVersion; Build = $ImageInfo.Build; SPBuild = $ImageInfo.SPBuild }
37 | Version = $ImageInfo.Version
38 | Build = $ImageInfo.Build
39 | Release = $null
40 | CodeName = $null
41 | Architecture = $ArchString[$ImageInfo.Architecture]
42 | Language = $ImageInfo.Languages[$ImageInfo.DefaultLanguageIndex]
43 | InstallationType = $ImageInfo.InstallationType
44 | Created = $ImageInfo.CreatedTime
45 | }
46 | If ($ImageFile.BaseName -ne 'install') { @('VersionTable', 'Release', 'CodeName', 'Created') | ForEach-Object -Process { $ImageData.PSObject.Properties.Remove($PSItem) } }
47 | $ImageData | Export-DataFile -File $ImageDataFile -ErrorAction:$ErrorActionPreference
48 | Break
49 | }
50 | 'Update'
51 | {
52 | $ImageData = Import-DataFile Install -ErrorAction:$ErrorActionPreference
53 | $CurrentVersion = Import-DataFile -CurrentVersion -ErrorAction:$ErrorActionPreference
54 | If ($ImageData.Build -eq '18362' -and $CurrentVersion.CurrentBuildNumber -eq '18363')
55 | {
56 | $ImageData.Version = $ImageData.Version.Replace($ImageData.Build, $CurrentVersion.CurrentBuildNumber)
57 | $ImageData.Build = $CurrentVersion.CurrentBuildNumber
58 | If ($CurrentVersion.BuildBranch.ToUpper().Split('_')[0] -eq '19H1') { $ImageData.CodeName = '19H2' }
59 | }
60 | ElseIf ($ImageData.Build -eq '19041' -and $CurrentVersion.CurrentBuildNumber -eq '19042')
61 | {
62 | $ImageData.Version = $ImageData.Version.Replace($ImageData.Build, $CurrentVersion.CurrentBuildNumber)
63 | $ImageData.Build = $CurrentVersion.CurrentBuildNumber
64 | If ($CurrentVersion.DisplayVersion -eq '20H2') { $ImageData.CodeName = $CurrentVersion.DisplayVersion }
65 | }
66 | ElseIf ($ImageData.Build -eq '19041' -and $CurrentVersion.CurrentBuildNumber -eq '19043')
67 | {
68 | $ImageData.Version = $ImageData.Version.Replace($ImageData.Build, $CurrentVersion.CurrentBuildNumber)
69 | $ImageData.Build = $CurrentVersion.CurrentBuildNumber
70 | If ($CurrentVersion.DisplayVersion -eq '21H1') { $ImageData.CodeName = $CurrentVersion.DisplayVersion }
71 | }
72 | ElseIf ($ImageData.Build -eq '19041' -and $CurrentVersion.CurrentBuildNumber -eq '19044')
73 | {
74 | $ImageData.Version = $ImageData.Version.Replace($ImageData.Build, $CurrentVersion.CurrentBuildNumber)
75 | $ImageData.Build = $CurrentVersion.CurrentBuildNumber
76 | If ($CurrentVersion.DisplayVersion -eq '21H2') { $ImageData.CodeName = $CurrentVersion.DisplayVersion }
77 | }
78 | ElseIf ($ImageData.Build -eq '19041' -and $CurrentVersion.CurrentBuildNumber -eq '19045')
79 | {
80 | $ImageData.Version = $ImageData.Version.Replace($ImageData.Build, $CurrentVersion.CurrentBuildNumber)
81 | $ImageData.Build = $CurrentVersion.CurrentBuildNumber
82 | If ($CurrentVersion.DisplayVersion -eq '22H2') { $ImageData.CodeName = $CurrentVersion.DisplayVersion }
83 | }
84 | Else
85 | {
86 | If ($ImageData.Build -eq '19041') { $ImageData.CodeName = '20H1' }
87 | Else { $ImageData.CodeName = $CurrentVersion.BuildBranch.ToUpper().Split('_')[0] }
88 | }
89 | $ImageData.Release = $CurrentVersion.ReleaseId
90 | @('Path', 'Index', 'VersionTable') | ForEach-Object -Process { $ImageData.PSObject.Properties.Remove($PSItem) }
91 | $ImageData.PSObject.TypeNames.Insert(0, 'System.IO.Optimized.Wim')
92 | $ImageData | Add-Member -MemberType NoteProperty -Name Optimized -Value (Get-Date -Format 'G')
93 | $ImageData | Export-DataFile -File InstallInfo -ErrorAction:$ErrorActionPreference
94 | Break
95 | }
96 | }
97 | $ImageData
98 | }
99 | }
--------------------------------------------------------------------------------
/Start-Optimize-BAU-TI.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Start-Optimize is a configuration call script for the Optimize-Offline module.
4 |
5 | .DESCRIPTION
6 | Start-Optimize automatically imports the configuration JSON file into the Optimize-Offline module.
7 |
8 | .EXAMPLE
9 | .\Start-Optimize.ps1
10 |
11 | This command will import all values set in the configuration JSON file into the Optimize-Offline module and begin the optimization process.
12 |
13 | .NOTES
14 | Start-Optimize requires that the configuration JSON file is present in the root path of the Optimize-Offline module.
15 | #>
16 | [CmdletBinding()]
17 | Param (
18 | [Parameter(Mandatory = $false)] [switch]$populateLists,
19 | [Parameter(Mandatory = $false)] [switch]$populateTemplates
20 | )
21 |
22 | $Global:Error.Clear()
23 |
24 | # Ensure we are running with full administrative permissions via RunAsTI function.
25 | function RunAsTI ($cmd) { $id='RunAsTI'; $sid=((whoami /user)-split' ')[-1]; $code=@'
26 | $ti=(whoami /groups)-like"*1-16-16384*"; $DM=[AppDomain]::CurrentDomain."DefineDynamicAss`embly"(1,1)."DefineDynamicMod`ule"(1)
27 | $D=@(); 0..5|% {$D+=$DM."DefineT`ype"("M$_",1179913,[ValueType])}; $I=[int32];$P=$I.module.gettype("System.Int`Ptr"); $U=[uintptr]
28 | $D+=$U; 4..6|% {$D+=$D[$_]."MakeB`yRefType"()};$M=$I.module.gettype("System.Runtime.Interop`Services.Mar`shal");$Z=[uintptr]::size
29 | $S=[string]; $F="kernel","advapi","advapi",($S,$S,$I,$I,$I,$I,$I,$S,$D[7],$D[8]),($U,$S,$I,$I,$D[9]),($U,$S,$I,$I,[byte[]],$I)
30 | 0..2|% {$9=$D[0]."DefinePInvokeMeth`od"(("CreateProcess","RegOpenKeyEx","RegSetValueEx")[$_],$F[$_]+'32',8214,1,$S,$F[$_+3],1,4)}
31 | $DF=0,($P,$I,$P),($I,$I,$I,$I,$P,$D[1]),($I,$S,$S,$S,$I,$I,$I,$I,$I,$I,$I,$I,[int16],[int16],$P,$P,$P,$P),($D[3],$P),($P,$P,$I,$I)
32 | 1..5|% {$k=$_;$n=1;$AveYo=1; $DF[$_]|% {$9=$D[$k]."DefineFie`ld"('f'+$n++,$_,6)}}; $T=@(); 0..5|% {$T+=$D[$_]."CreateT`ype"()}
33 | 0..5|% {nv "A$_" ([Activator]::CreateInstance($T[$_])) -force}; function F ($1,$2) {$T[0]."GetMeth`od"($1).invoke(0,$2)};
34 | if (!$ti) { $g=0; "TrustedInstaller","lsass"|% {if (!$g) {net1 start $_ 2>&1 >$null; $g=@(get-process -name $_ -ea 0|% {$_})[0]}}
35 | function M($1,$2,$3){$M."GetMeth`od"($1,[type[]]$2).invoke(0,$3)}; $H=@(); $Z,(4*$Z+16)|% {$H+=M "AllocHG`lobal" $I $_};
36 | M "WriteInt`Ptr" ($P,$P) ($H[0],$g.Handle); $A1.f1=131072;$A1.f2=$Z;$A1.f3=$H[0];$A2.f1=1;$A2.f2=1;$A2.f3=1;$A2.f4=1;$A2.f6=$A1
37 | $A3.f1=10*$Z+32;$A4.f1=$A3;$A4.f2=$H[1]; M "StructureTo`Ptr" ($D[2],$P,[boolean]) (($A2 -as $D[2]),$A4.f2,$false); $w=0x0E080600
38 | $out=@($null,"powershell -win 1 -nop -c iex `$env:A",0,0,0,$w,0,$null,($A4 -as $T[4]),($A5 -as $T[5])); F "CreateProcess" $out
39 | } else { $env:A=''; $PRIV=[uri].module.gettype("System.Diagnostics.Process")."GetMeth`ods"(42) |? {$_.Name -eq "SetPrivilege"}
40 | "SeSecurityPrivilege","SeTakeOwnershipPrivilege","SeBackupPrivilege","SeRestorePrivilege" |% {$PRIV.Invoke(0, @("$_",2))}
41 | $HKU=[uintptr][uint32]2147483651; $LNK=$HKU; $reg=@($HKU,"S-1-5-18",8,2,($LNK -as $D[9])); F "RegOpenKeyEx" $reg; $LNK=$reg[4]
42 | function SYM($1,$2){$b=[Text.Encoding]::Unicode.GetBytes("\Registry\User\$1");@($2,"SymbolicLinkValue",0,6,[byte[]]$b,$b.Length)}
43 | if (!$cmd) {$cmd='cmd'}; $r="start `"$id`" /high /w"; F "RegSetValueEx" (SYM $(($key-split'\\')[1]) $LNK)
44 | start cmd -args ("/q/x/d/r title $id && $r",$cmd) -wait -win 1; F "RegSetValueEx" (SYM ".Default" $LNK)
45 | } # lean and mean snippet by AveYo, 2018-2021
46 | '@; $key="Registry::HKEY_USERS\$sid\Volatile Environment"; $a1="`$id='$id';`$key='$key';";$a2="`$cmd='$($cmd-replace"'","''")';`n"
47 | sp $key $id $($a1,$a2,$code) -type 7 -force; $arg="$a1 `$env:A=(gi `$key).getvalue(`$id)-join'';rp `$key `$id -force; iex `$env:A"
48 | start powershell -args "-win 1 -nop -c $arg" -verb runas }
49 |
50 | $arguments = @()
51 | foreach ($param in $PSBoundParameters.GetEnumerator()) {
52 | $arguments += "-"+[string]$param.Key+$(If ($param.Value -notin @("True", "False")) {"="+$param.Value} Else {""})
53 | }
54 | if ((whoami)-ne"nt authority\system") {RunAsTI "powershell -c . ""$($MyInvocation.MyCommand.Path)"" $arguments; pause"; return}
55 |
56 | # Ensure the configuration JSON file exists.
57 | If (!(Test-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath Configuration.json))) {
58 | Write-Warning ('The required configuration JSON file does not exist: "{0}"' -f (Join-Path -Path $PSScriptRoot -ChildPath Configuration.json))
59 | Start-Sleep 3
60 | Exit
61 | }
62 |
63 | # If the configuration JSON or ordered collection list variables still exists from a previous session, remove them.
64 | If ((Test-Path -Path Variable:\ContentJSON) -or (Test-Path -Path Variable:\ConfigParams)) {
65 | Remove-Variable -Name ContentJSON, ConfigParams -ErrorAction Ignore
66 | }
67 |
68 | # Use a Try/Catch/Finally block in case the configuration JSON file URL formatting is invalid so we can catch it, correct its formatting and continue.
69 | Try {
70 | $ContentJSON = Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath Configuration.json) -Raw | ConvertFrom-Json
71 | }
72 | Catch [ArgumentException] {
73 | $ContentJSON = (Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath Configuration.json) -Raw).Replace('\', '\\') | Set-Content -Path (Join-Path -Path $Env:TEMP -ChildPath Configuration.json) -Encoding UTF8 -Force -PassThru
74 | $ContentJSON = $ContentJSON | ConvertFrom-Json
75 | Move-Item -Path (Join-Path -Path $Env:TEMP -ChildPath Configuration.json) -Destination $PSScriptRoot -Force
76 | $Global:Error.Remove($Error[-1])
77 | }
78 | Finally {
79 | $ContentJSON.PSObject.Properties.Remove('_Info')
80 | }
81 |
82 | # Convert the JSON object into a nested ordered collection list. We use the PSObject.Properties method to retain the JSON object order.
83 | $ConfigParams = [Ordered]@{
84 | populateLists = $populateLists
85 | populateTemplates = $populateTemplates
86 | }
87 | ForEach ($Name In $ContentJSON.PSObject.Properties.Name) {
88 | $Value = $ContentJSON.PSObject.Properties.Item($Name).Value
89 | If ($Value -is [PSCustomObject]) {
90 | $ConfigParams.$Name = [Ordered]@{ }
91 | ForEach ($Property in $Value.PSObject.Properties) {
92 | $ConfigParams.$Name[$Property.Name] = $Property.Value
93 | }
94 | }
95 | Else {
96 | $ConfigParams.$Name = $Value
97 | }
98 | }
99 |
100 | # Import the Optimize-Offline module and call it by passing the JSON configuration.
101 | If ($PSVersionTable.PSVersion.Major -gt 5) {
102 | Try {
103 | Import-Module Dism -SkipEditionCheck -Force -WarningAction Ignore -ErrorAction Stop
104 | }
105 | Catch {
106 | Write-Warning 'Failed to import the required Dism module.'
107 | Start-Sleep 3
108 | Exit
109 | }
110 | Try {
111 | Import-Module (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1) -SkipEditionCheck -Force -WarningAction Ignore -ErrorAction Stop
112 | }
113 | Catch {
114 | Write-Warning ('Failed to import the Optimize-Offline module: "{0}"' -f (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1))
115 | Start-Sleep 3
116 | Exit
117 | }
118 | }
119 | Else {
120 | Try {
121 | Import-Module (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1) -Force -WarningAction Ignore -ErrorAction Stop
122 | }
123 | Catch {
124 | Write-Warning ('Failed to import the Optimize-Offline module: "{0}"' -f (Join-Path -Path $PSScriptRoot -ChildPath Optimize-Offline.psm1))
125 | Start-Sleep 3
126 | Exit
127 | }
128 | }
129 |
130 | Optimize-Offline @ConfigParams
131 |
--------------------------------------------------------------------------------
/Content/Additional/SelectiveRegistry/RunAsTi.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | ; Context Menu entries to use RunAsTI - lean and mean snippet by AveYo, 2018-2022
4 | ; [FEATURES]
5 | ; - innovative HKCU load, no need for reg load / unload ping-pong; programs get the user profile
6 | ; - sets ownership privileges, high priority, and explorer support; get System if TI unavailable
7 | ; - accepts special characters in paths for which default run as administrator fails
8 | ; - show on the new 11 contextmenu via whitelisted id; plenty other available, f**k needing an app!
9 | ; 2022.01.28: workaround for 11 release (22000) hindering explorer as TI; fix 7 args
10 |
11 | [-HKEY_CLASSES_ROOT\RunAsTI]
12 | [-HKEY_CLASSES_ROOT\batfile\shell\setdesktopwallpaper]
13 | [-HKEY_CLASSES_ROOT\cmdfile\shell\setdesktopwallpaper]
14 | [-HKEY_CLASSES_ROOT\exefile\shell\setdesktopwallpaper]
15 | [-HKEY_CLASSES_ROOT\mscfile\shell\setdesktopwallpaper]
16 | [-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\setdesktopwallpaper]
17 | [-HKEY_CLASSES_ROOT\regfile\shell\setdesktopwallpaper]
18 | [-HKEY_CLASSES_ROOT\Folder\shell\setdesktopwallpaper]
19 | [-HKEY_CLASSES_ROOT\Directory\background\shell\extract]
20 | ; To remove entries, copy paste above into undo_RunAsTI.reg file, then import it
21 |
22 | ; RunAsTI on .bat
23 | [HKEY_CLASSES_ROOT\batfile\shell\setdesktopwallpaper]
24 | "MUIVerb"="Run as trustedinstaller"
25 | "HasLUAShield"=""
26 | "Icon"="powershell.exe,0"
27 | [HKEY_CLASSES_ROOT\batfile\shell\setdesktopwallpaper\command]
28 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% \"%L\""
29 |
30 | ; RunAsTI on .cmd
31 | [HKEY_CLASSES_ROOT\cmdfile\shell\setdesktopwallpaper]
32 | "MUIVerb"="Run as trustedinstaller"
33 | "HasLUAShield"=""
34 | "Icon"="powershell.exe,0"
35 | [HKEY_CLASSES_ROOT\cmdfile\shell\setdesktopwallpaper\command]
36 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% \"%L\""
37 |
38 | ; RunAsTI on .exe
39 | [HKEY_CLASSES_ROOT\exefile\shell\setdesktopwallpaper]
40 | "MUIVerb"="Run as trustedinstaller"
41 | "HasLUAShield"=""
42 | "Icon"="powershell.exe,0"
43 | [HKEY_CLASSES_ROOT\exefile\shell\setdesktopwallpaper\command]
44 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% \"%L\""
45 |
46 | ; RunAsTI on .msc
47 | [HKEY_CLASSES_ROOT\mscfile\shell\setdesktopwallpaper]
48 | "MUIVerb"="Run as trustedinstaller"
49 | "HasLUAShield"=""
50 | "Icon"="powershell.exe,0"
51 | [HKEY_CLASSES_ROOT\mscfile\shell\setdesktopwallpaper\command]
52 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% \"%L\""
53 |
54 | ; RunAsTI on .ps1
55 | [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\setdesktopwallpaper]
56 | "MUIVerb"="Run as trustedinstaller"
57 | "HasLUAShield"=""
58 | "Icon"="powershell.exe,0"
59 | [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\shell\setdesktopwallpaper\command]
60 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% powershell -nop -c iex((gc -lit '%L')-join[char]10)"
61 |
62 | ; RunAsTI on .reg
63 | [HKEY_CLASSES_ROOT\regfile\shell\setdesktopwallpaper]
64 | "MUIVerb"="Import as trustedinstaller"
65 | "HasLUAShield"=""
66 | "Icon"="powershell.exe,0"
67 | [HKEY_CLASSES_ROOT\regfile\shell\setdesktopwallpaper\command]
68 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% regedit /s \"%L\""
69 |
70 | ; RunAsTI on Folder
71 | [HKEY_CLASSES_ROOT\Folder\shell\setdesktopwallpaper]
72 | "MuiVerb"="Open as trustedinstaller"
73 | "HasLUAShield"=""
74 | "Icon"="powershell.exe,0"
75 | "AppliesTo"="NOT System.ParsingName:=\"::{645FF040-5081-101B-9F08-00AA002F954E}\""
76 | [HKEY_CLASSES_ROOT\Folder\shell\setdesktopwallpaper\command]
77 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% \"%L\""
78 |
79 | ; Open Powershell as trustedinstaller here
80 | [HKEY_CLASSES_ROOT\Directory\background\shell\extract]
81 | "MuiVerb"="Powershell as trustedinstaller"
82 | "HasLUAShield"=""
83 | "NoWorkingDirectory"=""
84 | "Position"="Middle"
85 | "Icon"="powershell.exe,0"
86 | [HKEY_CLASSES_ROOT\Directory\background\shell\extract\command]
87 | @="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -win 1 -nop -c iex((10..39|%%{(gp 'Registry::HKCR\\RunAsTI' $_ -ea 0).$_})-join[char]10); # --%% cmd /c set \"1=%V\"& start powershell -nop -noe -c $host.ui.RawUI.WindowTitle=$(whoami); set-location -lit $env:1"
88 |
89 | ; RunAsTI function
90 | [HKEY_CLASSES_ROOT\RunAsTI]
91 | "10"="function RunAsTI ($cmd,$arg) { $id='RunAsTI'; $key=\"Registry::HKU\\$(((whoami /user)-split' ')[-1])\\Volatile Environment\"; $code=@'"
92 | "11"=" $I=[int32]; $M=$I.module.gettype(\"System.Runtime.Interop`Services.Mar`shal\"); $P=$I.module.gettype(\"System.Int`Ptr\"); $S=[string]"
93 | "12"=" $D=@(); $T=@(); $DM=[AppDomain]::CurrentDomain.\"DefineDynami`cAssembly\"(1,1).\"DefineDynami`cModule\"(1); $Z=[uintptr]::size "
94 | "13"=" 0..5|% {$D += $DM.\"Defin`eType\"(\"AveYo_$_\",1179913,[ValueType])}; $D += [uintptr]; 4..6|% {$D += $D[$_].\"MakeByR`efType\"()}"
95 | "14"=" $F='kernel','advapi','advapi', ($S,$S,$I,$I,$I,$I,$I,$S,$D[7],$D[8]), ([uintptr],$S,$I,$I,$D[9]),([uintptr],$S,$I,$I,[byte[]],$I)"
96 | "15"=" 0..2|% {$9=$D[0].\"DefinePInvok`eMethod\"(('CreateProcess','RegOpenKeyEx','RegSetValueEx')[$_],$F[$_]+'32',8214,1,$S,$F[$_+3],1,4)}"
97 | "16"=" $DF=($P,$I,$P),($I,$I,$I,$I,$P,$D[1]),($I,$S,$S,$S,$I,$I,$I,$I,$I,$I,$I,$I,[int16],[int16],$P,$P,$P,$P),($D[3],$P),($P,$P,$I,$I)"
98 | "17"=" 1..5|% {$k=$_; $n=1; $DF[$_-1]|% {$9=$D[$k].\"Defin`eField\"('f' + $n++, $_, 6)}}; 0..5|% {$T += $D[$_].\"Creat`eType\"()}"
99 | "18"=" 0..5|% {nv \"A$_\" ([Activator]::CreateInstance($T[$_])) -fo}; function F ($1,$2) {$T[0].\"G`etMethod\"($1).invoke(0,$2)}"
100 | "19"=" $TI=(whoami /groups)-like'*1-16-16384*'; $As=0; if(!$cmd) {$cmd='control';$arg='admintools'}; if ($cmd-eq'This PC'){$cmd='file:'}"
101 | "20"=" if (!$TI) {'TrustedInstaller','lsass','winlogon'|% {if (!$As) {$9=sc.exe start $_; $As=@(get-process -name $_ -ea 0|% {$_})[0]}}"
102 | "21"=" function M ($1,$2,$3) {$M.\"G`etMethod\"($1,[type[]]$2).invoke(0,$3)}; $H=@(); $Z,(4*$Z+16)|% {$H += M \"AllocHG`lobal\" $I $_}"
103 | "22"=" M \"WriteInt`Ptr\" ($P,$P) ($H[0],$As.Handle); $A1.f1=131072; $A1.f2=$Z; $A1.f3=$H[0]; $A2.f1=1; $A2.f2=1; $A2.f3=1; $A2.f4=1"
104 | "23"=" $A2.f6=$A1; $A3.f1=10*$Z+32; $A4.f1=$A3; $A4.f2=$H[1]; M \"StructureTo`Ptr\" ($D[2],$P,[boolean]) (($A2 -as $D[2]),$A4.f2,$false)"
105 | "24"=" $Run=@($null, \"powershell -win 1 -nop -c iex `$env:R; # $id\", 0, 0, 0, 0x0E080600, 0, $null, ($A4 -as $T[4]), ($A5 -as $T[5]))"
106 | "25"=" F 'CreateProcess' $Run; return}; $env:R=''; rp $key $id -force; $priv=[diagnostics.process].\"GetM`ember\"('SetPrivilege',42)[0]"
107 | "26"=" 'SeSecurityPrivilege','SeTakeOwnershipPrivilege','SeBackupPrivilege','SeRestorePrivilege' |% {$priv.Invoke($null, @(\"$_\",2))}"
108 | "27"=" $HKU=[uintptr][uint32]2147483651; $NT='S-1-5-18'; $reg=($HKU,$NT,8,2,($HKU -as $D[9])); F 'RegOpenKeyEx' $reg; $LNK=$reg[4]"
109 | "28"=" function L ($1,$2,$3) {sp 'Registry::HKCR\\AppID\\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}' 'RunAs' $3 -force -ea 0"
110 | "29"=" $b=[Text.Encoding]::Unicode.GetBytes(\"\\Registry\\User\\$1\"); F 'RegSetValueEx' @($2,'SymbolicLinkValue',0,6,[byte[]]$b,$b.Length)}"
111 | "30"=" function Q {[int](gwmi win32_process -filter 'name=\"explorer.exe\"'|?{$_.getownersid().sid-eq$NT}|select -last 1).ProcessId}"
112 | "31"=" $11bug=($((gwmi Win32_OperatingSystem).BuildNumber)-eq'22000')-AND(($cmd-eq'file:')-OR(test-path -lit $cmd -PathType Container))"
113 | "32"=" if ($11bug) {'System.Windows.Forms','Microsoft.VisualBasic' |% {$9=[Reflection.Assembly]::LoadWithPartialName(\"'$_\")}}"
114 | "33"=" if ($11bug) {$path='^(l)'+$($cmd -replace '([\\+\\^\\%\\~\\(\\)\\[\\]])','{$1}')+'{ENTER}'; $cmd='control.exe'; $arg='admintools'}"
115 | "34"=" L ($key-split'\\\\')[1] $LNK ''; $R=[diagnostics.process]::start($cmd,$arg); if ($R) {$R.PriorityClass='High'; $R.WaitForExit()}"
116 | "35"=" if ($11bug) {$w=0; do {if($w-gt40){break}; sleep -mi 250;$w++} until (Q); [Microsoft.VisualBasic.Interaction]::AppActivate($(Q))}"
117 | "36"=" if ($11bug) {[Windows.Forms.SendKeys]::SendWait($path)}; do {sleep 7} while(Q); L '.Default' $LNK 'Interactive User'"
118 | "37"="'@; $V='';'cmd','arg','id','key'|%{$V+=\"`n`$$_='$($(gv $_ -val)-replace\"'\",\"''\")';\"}; sp $key $id $($V,$code) -type 7 -force -ea 0"
119 | "38"=" start powershell -args \"-win 1 -nop -c `n$V `$env:R=(gi `$key -ea 0).getvalue(`$id)-join''; iex `$env:R\" -verb runas"
120 | "39"="}; $A=([environment]::commandline-split'-[-]%+ ?',2)[1]-split'\"([^\"]+)\"|([^ ]+)',2|%{$_.Trim(' \"')}; RunAsTI $A[1] $A[2]; # AveYo, 2022.01.28"
121 | ;
122 |
--------------------------------------------------------------------------------
/Content/Additional/SelectiveRegistry/SelectiveRegistry.ps1:
--------------------------------------------------------------------------------
1 | RegHives -Load
2 | If($SelectiveRegistry.DisableWindowsUpgrade) {
3 |
4 | $TargetReleaseVersionInfo = $null
5 |
6 | Switch ($Global:InstallInfo.Build) {
7 | "17134" { $TargetReleaseVersionInfo = "1803" }
8 | "17763" { $TargetReleaseVersionInfo = "1809" }
9 | "18362" { $TargetReleaseVersionInfo = "1903" }
10 | "18363" { $TargetReleaseVersionInfo = "1909" }
11 | "19041" { $TargetReleaseVersionInfo = "2004" }
12 | "19042" { $TargetReleaseVersionInfo = "2009" }
13 | "19043" { $TargetReleaseVersionInfo = "21H1" }
14 | }
15 |
16 | If ($Global:InstallInfo.Build -ge "19044") {
17 | $TargetReleaseVersionInfo = "21H2"
18 | }
19 |
20 | If ($Global:InstallInfo.Build -ge "22500") {
21 | $TargetReleaseVersionInfo = "22H2"
22 | }
23 |
24 | If ($TargetReleaseVersionInfo){
25 |
26 | Log $OptimizeData.SelectiveRegistryWindowsUpgrade
27 |
28 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUOptions" -Type DWord -Value "2"
29 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Type DWord -Value "1"
30 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferUpdatePeriod" -Type DWord -Value "1"
31 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferUpgrade" -Type DWord -Value "1"
32 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferUpgradePeriod" -Type DWord -Value "1"
33 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "TargetReleaseVersion" -Type DWord -Value "1"
34 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "TargetReleaseVersionInfo" -Type String -Value $TargetReleaseVersionInfo
35 |
36 | If ($Global:InstallInfo.Build -ge "17134" -and $Global:InstallInfo.Build -le "20348") { RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ProductVersion" -Type String -Value "Windows 10" }
37 |
38 | If ($Global:InstallInfo.Build -ge "22000") { RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ProductVersion" -Type String -Value "Windows 11" }
39 |
40 | }
41 | Start-Sleep 1
42 | }
43 | If($SelectiveRegistry.DisableWindowsUpdateMicrosoft) {
44 | Log $OptimizeData.SelectiveRegistryWindowsUpdateMS
45 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DoNotConnectToWindowsUpdateInternetLocations" -Type DWord -Value "1"
46 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DisableWindowsUpdateAccess" -Type DWord -Value "1"
47 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUServer" -Type String -Value " "
48 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUStatusServer" -Type String -Value " "
49 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "UpdateServiceUrlAlternate" -Type String -Value " "
50 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Type DWord -Value "1"
51 | Start-Sleep 1
52 | }
53 |
54 | If($SelectiveRegistry.DisableDriverUpdate) {
55 | Log $OptimizeData.SelectiveRegistryDriverUpdate
56 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -Type DWord -Value "1"
57 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -Type DWord -Value "1"
58 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -Type DWord -Value "1"
59 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -Type DWord -Value "0"
60 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "SearchOrderConfig" -Type DWord -Value "1"
61 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -Type DWord -Value "1"
62 | Start-Sleep 1
63 | }
64 |
65 | If($SelectiveRegistry.DormantOneDrive) {
66 | Log $OptimizeData.SelectiveRegistryDormantOneDrive
67 | RegKey -Path "HKLM:\WIM_HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "OneDriveSetup" -Type DWord -Value "0"
68 | Start-Sleep 1
69 | }
70 |
71 | # classic search in explorer
72 | If($SelectiveRegistry.ClassicSearchExplorer -and $Global:InstallInfo.Build -ge '18363') {
73 |
74 | Log $OptimizeData.SelectiveRegistryClassicSearchExplorer
75 |
76 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Classes\CLSID\{1d64637d-31e9-4b06-9124-e83fb178ac6e}\TreatAs" -Name "(default)" -Value "{64bc32b5-4eec-4de7-972d-bd8bd0324537}" -Type String -Force
77 |
78 | Start-Sleep 1
79 | }
80 |
81 | If($SelectiveRegistry.RemoveTaskbarPinnedIcons){
82 |
83 | Log $OptimizeData.SelectiveRegistryRemoveTaskbarPinnedIcons
84 |
85 | ## Disable taskbar taskview button
86 | RegKey -Path "HKLM:\WIM_HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type Dword -Value "0" -Force
87 |
88 | If($Global:InstallInfo.Build -ge '18362') {
89 | #Hide MeetNow icon in taskbar
90 | RegKey -Path "HKLM:\WIM_HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HideSCAMeetNow" -Type dword -Value "1"
91 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "HideSCAMeetNow" -Type dword -Value "1"
92 | }
93 |
94 | if($Global:InstallInfo.Build -le '19044'){
95 | RegKey -Path "HKLM:\WIM_HKCU\Software\Policies\Microsoft\Windows\Explorer" -Name "NoPinningStoreToTaskbar" -Value 1 -Type DWord
96 | RegKey -Path "HKLM:\WIM_HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband\AuxilliaryPins" -Name "MailPin" -Value 2 -Type DWord
97 | RegKey -Path "HKLM:\WIM_HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Value 0 -Type DWord
98 | }
99 |
100 | # Disable News & Interests icon
101 | RegKey -Path "HKLM:\WIM_HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds" -Name "ShellFeedsTaskbarViewMode" -Type dword -Value "2"
102 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name "EnableFeeds" -Type dword -Value "0"
103 |
104 | If($Global:InstallInfo.Build -ge '22000') {
105 | #Remove Chat icon in taskbar
106 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Policies\Microsoft\Windows\Windows Chat" -Name "ChatIcon" -Type dword -Value "3"
107 | RegKey -Path "HKLM:\WIM_HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Type dword -Value "0"
108 |
109 | ## Disable widgets button
110 | RegKey -Path "HKLM:\WIM_HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Type Dword -Value "0" -Force
111 | }
112 |
113 | Start-Sleep 1
114 |
115 | }
116 |
117 | If($SelectiveRegistry.W11ClassicContextMenu -and $Global:InstallInfo.Build -ge '22000') {
118 | Log $OptimizeData.SelectiveRegistryW11ClassicContextMenu
119 | # Classic context menus
120 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" -Name "(default)" -Value "" -Type String -Force
121 | Start-Sleep 1
122 | }
123 |
124 | if($SelectiveRegistry.DisableTeamsApp -and $Global:InstallInfo.Build -ge '10240') {
125 | Log $OptimizeData.SelectiveRegistryDisableTeamsApp
126 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -Name "ConfigureChatAutoInstall" -Value "0" -Type DWord -Force
127 | Start-Sleep 1
128 | }
129 |
130 | if($SelectiveRegistry.DisableVirtualizationSecurity -and $Global:InstallInfo.Build -ge '22000') {
131 | Log $OptimizeData.SelectiveRegistryDisableVirtualizationSecurity
132 | RegKey -Path "HKLM:\WIM_HKLM_SYSTEM\ControlSet001\Control\DeviceGuard\Scenarios" -Name "HypervisorEnforcedCodeIntegrity" -Value "0" -Type DWord -Force
133 | RegKey -Path "HKLM:\WIM_HKLM_SYSTEM\ControlSet001\Control\DeviceGuard" -Name "EnableVirtualizationBasedSecurity" -Value "0" -Type DWord -Force
134 | Start-Sleep 1
135 | }
136 |
137 |
138 |
139 | if ($SelectiveRegistry.ExplorerUIRibbon) {
140 | if ($Global:InstallInfo.Build -le "19044"){
141 | Log $OptimizeData.SelectiveRegistryExplorerUIRibbon
142 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}" -Value "" -Type String -Force
143 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}" -Value "" -Type String -Force
144 | Start-Sleep 1
145 | } elseif ($Global:InstallInfo.Build -eq "22000") {
146 | Log $OptimizeData.SelectiveRegistryExplorerUIRibbon
147 | # RegKey -Path "HKLM:\WIM_HKCU\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32" -Name "(default)" -Value "" -Type String -Force
148 | RegKey -Path "HKLM:\WIM_HKLM_SOFTWARE\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32" -Name "(default)" -Value "" -Type String -Force
149 | Start-Sleep 1
150 | }
151 | }
152 |
153 | RegHives -Unload
154 |
155 | if($SelectiveRegistry.AmoledBlackTheme -and $Global:InstallInfo.Build -ge '10240') {
156 | Log $OptimizeData.SelectiveRegistryAmoledBlackTheme
157 | Import-Registry -Path (Get-ChildItem -Path $OptimizeOffline.SelectiveRegistry -Filter AMOLED_black_theme.reg).FullName
158 | Start-Sleep 1
159 | }
160 |
161 | if($SelectiveRegistry.RunAsTiContextMenu){
162 | Log $OptimizeData.SelectiveRegistryRunAsTiContextMenu
163 | Import-Registry -Path (Get-ChildItem -Path $OptimizeOffline.SelectiveRegistry -Filter RunAsTi.reg).FullName
164 | Start-Sleep 1
165 | }
166 |
167 | Clear-Host
168 |
--------------------------------------------------------------------------------
/en-US/Optimize-Offline.strings.psd1:
--------------------------------------------------------------------------------
1 | ConvertFrom-StringData -StringData @'
2 | ActiveMountPoints = Active mount points detected. Performing clean-up.
3 | FailedToCreateWorkingFileStructure = Failed to create the working file structure.
4 | InvalidWindowsInstallMedia = "{0}" does not contain valid Windows Installation media.
5 | ExportingMedia = Exporting media from "{0}"
6 | CopyingImage = Copying {0} from "{1}"
7 | FailedToReturnInstallImage = Failed to return the Install Image from "{0}"
8 | SelectWindowsEdition = Select the Windows Edition to Optimize.
9 | FailedToRetrieveImageMetadata = Failed to retrieve the necessary image metadata from the {0}
10 | UnsupportedImageVersion = Unsupported Image Version: [{0}]
11 | UnsupportedImageArch = Unsupported Image Architecture: [{0}]
12 | UnsupportedImageType = Unsupported Image Installation Type: [{0}]
13 | UnsupportedImageBuild = Unsupported Image Build: [{0}]
14 | ExportingInstallToWim = Exporting {0} to {1}
15 | FailedExportingInstallToWim = Failed to export {0} to {1}
16 | SupportedImageBuild = Supported Image Build: [{0}]
17 | MountingImage = Mounting {0}
18 | FailedMountingImage = Failed to Mount {0}
19 | PreOptimizedImageHealthHealthy = Pre-Optimization Image Health State: [Healthy]
20 | PreOptimizedImageHealthCorrupted = The image has been flagged for corruption. Further servicing is required before the image can be optimized.
21 | RemovingWindowsApp = Removing Provisioned App Package: {0}
22 | FailedRemovingWindowsApps = Failed to Remove Provisioned App Packages.
23 | SystemAppsWarning = Do NOT remove any System Application if you are unsure of its impact on a live installation.
24 | RemovingSystemApp = Removing System App: {0}
25 | FailedRemovingSystemApp = Failed to Remove System App: {0}
26 | FailedRemovingSystemApps = Failed to Remove System Apps.
27 | DisableDefender = Disabling Defender Start-up and Feature Packages.
28 | RemovingBiometricCapability = Removing Windows Biometric Capability: {0}
29 | FailedRemovingBiometricCapability = Failed to Remove Windows Biometric Capabilities.
30 | DisablingDefenderOptionalFeature = Disabling Optional Feature: Windows-Defender-Default-Definitions
31 | FailedDisablingDefenderOptionalFeature = Failed to Disable Optional Feature: Windows-Defender-Default-Definitions
32 | ImportingCustomAppAssociations = Importing Custom App Associations.
33 | FailedImportingCustomAppAssociations = Failed to Import Custom App Associations.
34 | RemovingWindowsCapability = Removing Windows Capability: {0}
35 | FailedRemovingWindowsCapabilities = Failed to Remove Windows Capabilities.
36 | RemovingWindowsPackage = Removing Windows Package: {0}
37 | FailedRemovingWindowsPackages = Failed to Remove Windows Packages.
38 | DisablingUnsafeOptionalFeature = Disabling Optional Feature: {0}
39 | FailedDisablingUnsafeOptionalFeature = Failed to Disable Optional Feature: {0}
40 | DisablingOptionalFeature = Disabling Optional Feature: {0}
41 | FailedDisablingOptionalFeatures = Failed to Disable Optional Features.
42 | EnablingOptionalFeature = Enabling Optional Feature: {0}
43 | FailedEnablingOptionalFeatures = Failed to Enable Optional Features.
44 | IntegratingDeveloperMode = Integrating the Developer Mode Feature Package.
45 | FailedIntegratingDeveloperMode = Failed to Integrate the Developer Mode Feature Package.
46 | IntegratingWindowsStore = Integrating the Windows Store Application Packages.
47 | FailedIntegratingWindowsStore = Failed to Integrate the Windows Store Application Packages.
48 | IntegratingMicrosoftEdge = Integrating the Microsoft Edge Browser Application Packages.
49 | FailedIntegratingMicrosoftEdge = Failed to Integrate the Microsoft Edge Browser Application Packages.
50 | IntegratingMicrosoftEdgeChromium = Integrating the Microsoft Edge Chromium Application Package.
51 | FailedIntegratingMicrosoftEdgeChromium = Failed to Integrate the Microsoft Edge Chromium Application Package.
52 | IntegratingMicrosoftEdgePolicies = Integrating the Microsoft Edge Administrative Policy Templates.
53 | FailedIntegratingMicrosoftEdgePolicies = Failed to Integrate the Microsoft Edge Administrative Policy Templates.
54 | IntegratingWin32Calc = Integrating the Win32 Calculator.
55 | FailedIntegratingWin32Calc = Failed to Integrate the Win32 Calculator.
56 | IntegratingDataDedup = Integrating the Data Deduplication Packages.
57 | FailedIntegratingDataDedup = Failed to Integrate the Data Deduplication Packages.
58 | IntegratingDaRT10 = Integrating Microsoft DaRT 10 and Windows {0} Debugging Tools into {1}
59 | FailedIntegratingDaRT10 = Failed to Integrate Microsoft DaRT 10.
60 | MissingRequiredRegistryData = Missing the required localized data file for optimizing the registry: {0}
61 | ApplyingRegistrySettings = Applying Optimized Registry Settings.
62 | FailedApplyingRegistrySettings = Failed to Apply Optimized Registry Settings.
63 | FailedImportingRegistryLocalizedData = Failed to import the registry localized data file: {0}
64 | ApplyingSetupContent = Applying Setup Content.
65 | FailedApplyingSetupContent = Failed to Apply Setup Content.
66 | ApplyingWallpaper = Applying Wallpaper.
67 | FailedApplyingWallpaper = Failed to Apply Wallpaper.
68 | ApplyingSystemLogo = Applying System Logo.
69 | FailedApplyingSystemLogo = Failed to Apply System Logo.
70 | ApplyingLockScreen = Applying Lock Screen.
71 | FailedApplyingLockScreen = Failed to Apply Lock Screen.
72 | ImportingRegistryTemplate = Importing Registry Template: {0}
73 | FailedImportingRegistryTemplate = Failed to Import Registry Template: {0}
74 | ApplyingLayoutModification = Applying LayoutModification.
75 | FailedApplyingLayoutModification = Failed to Apply LayoutModification.
76 | ApplyingAnswerFile = Applying Answer File.
77 | FailedApplyingAnswerFile = Failed to Apply Answer File.
78 | InjectingDriverPackages = Injecting Driver Packages into {0}
79 | FailedInjectingDriverPackages = Failed to Inject Driver Packages into {0}
80 | EnablingNetFx3 = Enabling Optional Feature: NetFx3
81 | FailedEnablingNetFx3 = Failed to Enable Optional Feature: NetFx3
82 | ComponentStoreCleanup = Performing a Clean-up of the {0} Component Store. This may take some time to complete.
83 | FailedComponentStoreCleanup = Failed to perform a Clean-up of the {0} Component Store.
84 | ComponentStorePendingInstallations = Cannot perform a clean-up of the Component Store while there are pending installations.
85 | CleanupStartMenu = Cleaning-up the Start Menu Layout.
86 | FailedCleanupStartMenu = Failed to Clean-up the Start Menu Layout.
87 | CreatingPackageSummaryLog = Creating a Package Summary Log.
88 | PostOptimizedImageHealthHealthy = Post-Optimization Image Health State: [Healthy]
89 | PostOptimizedImageHealthCorrupted = The image has been flagged for corruption. Discarding optimizations.
90 | SavingDismountingImage = Saving and Dismounting {0}
91 | FailedSavingDismountingImage = Failed to Save and Dismount {0}
92 | RebuildingExportingImage = Rebuilding and Exporting {0}
93 | FailedRebuildingExportingImage = Failed to Rebuild and Export {0}
94 | RebuildingExportingCompressed = Rebuilding and Exporting {0} using {1} compression.
95 | FailedRebuildingExportingCompressed = Failed to Rebuild and Export {0} using {1} compression.
96 | FailedToUpdateImageMetadata = Failed to Update the Image Metadata for the {0}
97 | MissingRequiredDataFiles = Missing the required files to update the image metadata for the {0}
98 | OptimizingInstallMedia = Optimizing the Installation Media File Structure.
99 | CreatingISO = Creating a {0} Bootable Windows Installation Media ISO.
100 | FailedCreatingISO = Failed to Create a {0} Bootable Windows Installation Media ISO.
101 | FinalizingOptimizations = Finalizing Optimizations.
102 | OptimizationsCompleted = {0} completed in [{1}] minutes with [{2}] errors.
103 | TerminatingOptimizations = Discarding any Images and Terminating Optimizations.
104 | Populating = populating
105 | SelectiveRegistryWindowsUpgrade = Disabling Windows Upgrade
106 | SelectiveRegistryWindowsUpdateMS = Disabling Windows update contacting Microsoft servers
107 | SelectiveRegistryDriverUpdate = Disabling automatic driver update
108 | SelectiveRegistryDormantOneDrive = Enabling dormant OneDrive fix
109 | SelectiveRegistryDisable3rdPartyApps = Disabling 3rd party apps
110 | SelectiveRegistryW11ClassicContextMenu = Setting W11 classic context menu
111 | SelectiveRegistryExplorerUIRibbon = Enabling explorer classic UI ribbon
112 | SelectiveRegistryRemoveTaskbarPinnedIcons = Removing taskbar pinned icons
113 | SelectiveRegistryDisableVirtualizationSecurity = Disabling virtualization security
114 | SelectiveRegistryAmoledBlackTheme = Adding AMOLED pitch-black theme
115 | SelectiveRegistryClassicSearchExplorer = Setting classic search explorer
116 | SelectiveRegistryDisableTeamsApp = Disabling Microsoft Teams autostart entry
117 | SelectiveRegistryRunAsTiContextMenu = Adding Powershell as trusted installer context menu entry
118 | ServiceStartBoot = Boot
119 | ServiceStartSystem = System
120 | ServiceStartAutomatic = Automatic
121 | ServiceStartManual = Manual
122 | ServiceStartDisabled = Disabled
123 | ServiceModifying = Modifying windows service
124 | ServicesModifying = Modifying windows services
125 | DeliveryOptimizationBypass = Setting delivery optimization to bypass mode
126 | ServicesRemovalFailed = Failed removing windows services
127 | ChooseServicesTitle = Choose services to remove
128 | '@
129 |
--------------------------------------------------------------------------------
/Content/Additional/SelectiveRegistry/WindowsPhotoViewer.reg:
--------------------------------------------------------------------------------
1 | Windows Registry Editor Version 5.00
2 |
3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations]
4 | ".bmp"="PhotoViewer.FileAssoc.BITMAP"
5 | ".dib"="PhotoViewer.FileAssoc.BITMAP"
6 | ".jpg"="PhotoViewer.FileAssoc.JPEG"
7 | ".jpe"="PhotoViewer.FileAssoc.JPEG"
8 | ".jpeg"="PhotoViewer.FileAssoc.JPEG"
9 | ".jxr"="PhotoViewer.FileAssoc.JPEG"
10 | ".jfif"="PhotoViewer.FileAssoc.JFIF"
11 | ".wdp"="PhotoViewer.FileAssoc.WDP"
12 | ".png"="PhotoViewer.FileAssoc.PNG"
13 | ".gif"="PhotoViewer.FileAssoc.TIFF"
14 | ".tiff"="PhotoViewer.FileAssoc.TIFF"
15 | ".tif"="PhotoViewer.FileAssoc.TIFF"
16 |
17 | ; Bitmap
18 |
19 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.BITMAP]
20 | "ImageOptionFlags"=dword:00000001
21 | "FriendlyTypeName"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,\
22 | 00,46,00,69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
23 | 77,00,73,00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,\
24 | 00,65,00,72,00,5c,00,50,00,68,00,6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,\
25 | 65,00,72,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,35,00,36,00,00,\
26 | 00
27 |
28 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.BITMAP\DefaultIcon]
29 | @="%SystemRoot%\\System32\\imageres.dll,-70"
30 |
31 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.BITMAP\shell]
32 |
33 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.BITMAP\shell\open]
34 |
35 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.BITMAP\shell\open\command]
36 | @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
37 | 00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
38 | 6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
39 | 00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
40 | 25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
41 | 00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
42 | 6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
43 | 00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
44 | 5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
45 | 00,31,00,00,00
46 |
47 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.BITMAP\shell\open\DropTarget]
48 | "CLSID"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"
49 |
50 |
51 | ; JFIF
52 |
53 |
54 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF]
55 | "EditFlags"=dword:00010000
56 | "ImageOptionFlags"=dword:00000001
57 | "FriendlyTypeName"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,\
58 | 00,46,00,69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
59 | 77,00,73,00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,\
60 | 00,65,00,72,00,5c,00,50,00,68,00,6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,\
61 | 65,00,72,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,35,00,35,00,00,\
62 | 00
63 |
64 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\DefaultIcon]
65 | @="%SystemRoot%\\System32\\imageres.dll,-72"
66 |
67 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell]
68 |
69 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell\open]
70 | "MuiVerb"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,\
71 | 69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,\
72 | 00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,\
73 | 72,00,5c,00,70,00,68,00,6f,00,74,00,6f,00,76,00,69,00,65,00,77,00,65,00,72,\
74 | 00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,34,00,33,00,00,00
75 |
76 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell\open\command]
77 | @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
78 | 00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
79 | 6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
80 | 00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
81 | 25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
82 | 00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
83 | 6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
84 | 00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
85 | 5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
86 | 00,31,00,00,00
87 |
88 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JFIF\shell\open\DropTarget]
89 | "CLSID"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"
90 |
91 |
92 | ; Jpeg
93 |
94 |
95 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JPEG]
96 | "EditFlags"=dword:00010000
97 | "ImageOptionFlags"=dword:00000001
98 | "FriendlyTypeName"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,\
99 | 00,46,00,69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
100 | 77,00,73,00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,\
101 | 00,65,00,72,00,5c,00,50,00,68,00,6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,\
102 | 65,00,72,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,35,00,35,00,00,\
103 | 00
104 |
105 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JPEG\DefaultIcon]
106 | @="%SystemRoot%\\System32\\imageres.dll,-72"
107 |
108 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JPEG\shell]
109 |
110 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JPEG\shell\open]
111 | "MuiVerb"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,\
112 | 69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,\
113 | 00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,\
114 | 72,00,5c,00,70,00,68,00,6f,00,74,00,6f,00,76,00,69,00,65,00,77,00,65,00,72,\
115 | 00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,34,00,33,00,00,00
116 |
117 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JPEG\shell\open\command]
118 | @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
119 | 00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
120 | 6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
121 | 00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
122 | 25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
123 | 00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
124 | 6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
125 | 00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
126 | 5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
127 | 00,31,00,00,00
128 |
129 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.JPEG\shell\open\DropTarget]
130 | "CLSID"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"
131 |
132 | ; PNG
133 |
134 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.PNG]
135 | "ImageOptionFlags"=dword:00000001
136 | "FriendlyTypeName"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,\
137 | 00,46,00,69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,\
138 | 77,00,73,00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,\
139 | 00,65,00,72,00,5c,00,50,00,68,00,6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,\
140 | 65,00,72,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,35,00,37,00,00,\
141 | 00
142 |
143 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.PNG\DefaultIcon]
144 | @="%SystemRoot%\\System32\\imageres.dll,-71"
145 |
146 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.PNG\shell]
147 |
148 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.PNG\shell\open]
149 |
150 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.PNG\shell\open\command]
151 | @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
152 | 00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
153 | 6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
154 | 00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
155 | 25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
156 | 00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
157 | 6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
158 | 00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
159 | 5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
160 | 00,31,00,00,00
161 |
162 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.PNG\shell\open\DropTarget]
163 | "CLSID"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"
164 |
165 | ; WDP
166 |
167 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.WDP]
168 | "EditFlags"=dword:00010000
169 | "ImageOptionFlags"=dword:00000001
170 |
171 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.WDP\DefaultIcon]
172 | @="%SystemRoot%\\System32\\wmphoto.dll,-400"
173 |
174 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.WDP\shell]
175 |
176 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.WDP\shell\open]
177 | "MuiVerb"=hex(2):40,00,25,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,\
178 | 69,00,6c,00,65,00,73,00,25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,\
179 | 00,20,00,50,00,68,00,6f,00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,\
180 | 72,00,5c,00,70,00,68,00,6f,00,74,00,6f,00,76,00,69,00,65,00,77,00,65,00,72,\
181 | 00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,00,30,00,34,00,33,00,00,00
182 |
183 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.WDP\shell\open\command]
184 | @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
185 | 00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
186 | 6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
187 | 00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
188 | 25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
189 | 00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
190 | 6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
191 | 00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
192 | 5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
193 | 00,31,00,00,00
194 |
195 | [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\PhotoViewer.FileAssoc.WDP\shell\open\DropTarget]
196 | "CLSID"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"
197 |
198 |
--------------------------------------------------------------------------------
/Src/GUI/Configuration_definition.json:
--------------------------------------------------------------------------------
1 | {
2 | "Main": {
3 | "Label": "Main",
4 | "Column": 1,
5 | "Controls": [
6 | {
7 | "Name": "DormantDefender",
8 | "Label": "Disable Windows Defender/Security",
9 | "Type": "Switch",
10 | "Binding": "DormantDefender",
11 | "Description": "Disable Windows defender while retaining the option to reactivate it."
12 | },
13 | {
14 | "Name": "Registry",
15 | "Label": "Apply Registry tweaks",
16 | "Type": "Switch",
17 | "Binding": "Registry",
18 | "Description": "For the specifics check file: .\\Src\\Public\\Set-RegistryProperties.ps1"
19 | },
20 | {
21 | "Name": "ComponentCleanup",
22 | "Label": "Clean the Component Store",
23 | "Type": "Switch",
24 | "Binding": "ComponentCleanup",
25 | "Description": "compresses all superseded components, thus reducing the size of the Component Store"
26 | },
27 | {
28 | "Name": "Win32Calc",
29 | "Label": "Integrate classic windows calculator",
30 | "Type": "Switch",
31 | "Binding": "Win32Calc",
32 | "Description": "Integrates the traditional Win32 Calculator into the image."
33 | },
34 | {
35 | "Name": "DeveloperMode",
36 | "Label": "Developer mode",
37 | "Type": "Switch",
38 | "Binding": "DeveloperMode",
39 | "Description": "Enables developer mode"
40 | },
41 | {
42 | "Name": "WindowsStore",
43 | "Label": "Integrate Windows Store",
44 | "Type": "Switch",
45 | "Binding": "WindowsStore",
46 | "Description": "Integrate Windows Store"
47 | },
48 | {
49 | "Name": "Dedup",
50 | "Label": "Integrate Windows Server Data Deduplication",
51 | "Type": "Switch",
52 | "Binding": "Dedup",
53 | "Description": "Integrates the Windows Server Data Deduplication Feature into the image."
54 | },
55 | {
56 | "Name": "MicrosoftEdge",
57 | "Label": "Integrate Microsoft Edge Chromium",
58 | "Type": "Switch",
59 | "Binding": "MicrosoftEdge",
60 | "Description": "Only works on windows 10 builds without Edge Chromium",
61 | "Restrictions": [
62 | {
63 | "Build": "18362",
64 | "Criteria": "min"
65 | },
66 | {
67 | "Build": "19041",
68 | "Criteria": "max"
69 | }
70 | ]
71 | },
72 | {
73 | "Name": "ISO",
74 | "Label": "Prompt at boot",
75 | "Type": "ComboBox",
76 | "Description": "Prompt at boot",
77 | "Values": ["Prompt", "No-Prompt"],
78 | "Binding": "ISO",
79 | "ShowNone": false
80 | },
81 | {
82 | "Name": "CompressionType",
83 | "Label": "WIM/ESD compression level",
84 | "Type": "ComboBox",
85 | "Description": "WIM/ESD compression level",
86 | "Values": ["None", "Fast", "Maximum", "Solid"],
87 | "Binding": "CompressionType",
88 | "ShowNone": false
89 | },
90 | {
91 | "Name": "ShutDownOnComplete",
92 | "Label": "Turn off pc on script completion",
93 | "Type": "Switch",
94 | "Binding": "ShutDownOnComplete",
95 | "Description": "Turn off pc on script completion, when clicking the process button"
96 | }
97 | ]
98 | },
99 | "Additional": {
100 | "Label": "Additional",
101 | "Column": 0,
102 | "Controls": [
103 | {
104 | "Name": "Setup",
105 | "Label": "Apply Setup Content",
106 | "Type": "Switch",
107 | "Binding": "Additional.Setup",
108 | "Description": "Integrates user-specific content added to the 'Content/Additional' directory into the image when enabled"
109 | },
110 | {
111 | "Name": "Wallpaper",
112 | "Label": "Apply Wallpaper",
113 | "Type": "Switch",
114 | "Binding": "Additional.Wallpaper",
115 | "Description": "Integrates 'Content\\Additional\\Wallpaper\\Windows 10 HD' wallpapers in the image"
116 | },
117 | {
118 | "Name": "SystemLogo",
119 | "Label": "Apply System Logo",
120 | "Type": "Switch",
121 | "Binding": "Additional.SystemLogo",
122 | "Description": "Integrates a custom system logo into the image. Place the logo in 'Content\\Additional\\SystemLogo'"
123 | },
124 | {
125 | "Name": "LockScreen",
126 | "Label": "Apply LockScreen",
127 | "Type": "Switch",
128 | "Binding": "Additional.LockScreen",
129 | "Description": "Converts and integrates a custom lockscreen into the image. Place the lockscreen files into 'Content\\Additional\\LockScreen'"
130 | },
131 | {
132 | "Name": "RegistryTemplates",
133 | "Label": "Apply Additional Registry",
134 | "Type": "Switch",
135 | "Binding": "Additional.RegistryTemplates",
136 | "Description": "Custom registry template (.reg) files placed in the '\\Content\\Additional\\RegistryTemplates' folder are imported by Optimize-Offline into the offline image's appropriate registry hive."
137 | },
138 | {
139 | "Name": "LayoutModification",
140 | "Label": "Apply custom Start Menu layout",
141 | "Type": "Switch",
142 | "Binding": "Additional.LayoutModification",
143 | "Description": "Imports a custom LayoutModification.xml to provision the Start layout.If adding additional user content, place any custom Start Menu layout XML/JSON (LayoutModification.xml/LayoutModification.json) file to be added to the image in '\\Content\\Additional\\LayoutModification'"
144 | },
145 | {
146 | "Name": "Unattend",
147 | "Label": "Apply answer file",
148 | "Type": "Switch",
149 | "Binding": "Additional.Unattend",
150 | "Description": "Place the answer file (unattend.xml) into '\\Content\\Additional\\Unattend' folder"
151 | },
152 | {
153 | "Name": "Drivers",
154 | "Label": "Integrate Windows drivers",
155 | "Type": "Switch",
156 | "Binding": "Additional.Drivers",
157 | "Description": "Place the drivers into '\\Content\\Additional\\Drivers' folder"
158 | },
159 | {
160 | "Name": "NetFx3",
161 | "Label": "Integrate .Net Framework 3.5",
162 | "Type": "Switch",
163 | "Binding": "Additional.NetFx3",
164 | "Description": "Integrates the .NET Framework 3 payload packages into the image and enables the NetFx3 optional feature. Works only when input is an ISO image."
165 | }
166 | ]
167 | },
168 | "SelectiveRegistry": {
169 | "Label": "Selective registry",
170 | "Column": 0,
171 | "Controls": [
172 | {
173 | "Name": "DisableWindowsUpgrade",
174 | "Label": "Disable Windows upgrade",
175 | "Type": "Switch",
176 | "Binding": "SelectiveRegistry.DisableWindowsUpgrade",
177 | "Description": "Disables the ability to upgrade to newer versions of Windows"
178 | },
179 | {
180 | "Name": "DisableWindowsUpdateMicrosoft",
181 | "Label": "Disabling Windows update contacting Microsoft servers",
182 | "Type": "Switch",
183 | "Binding": "SelectiveRegistry.DisableWindowsUpdateMicrosoft",
184 | "Description": "This disables completely the windows update services and Microsoft Store downloading"
185 | },
186 | {
187 | "Name": "DisableDriverUpdate",
188 | "Label": "Disable Windows driver update",
189 | "Type": "Switch",
190 | "Binding": "SelectiveRegistry.DisableDriverUpdate",
191 | "Description": "Disabled Windows update from automatically updating drivers"
192 | },
193 | {
194 | "Name": "DormantOneDrive",
195 | "Label": "Disable Microsoft OneDrive",
196 | "Type": "Switch",
197 | "Binding": "SelectiveRegistry.DormantOneDrive",
198 | "Description": "Disables Onedrive installation after OOBE run"
199 | },
200 | {
201 | "Name": "Disable3rdPartyApps",
202 | "Label": "Disable 3rd party app installation",
203 | "Type": "Switch",
204 | "Binding": "SelectiveRegistry.Disable3rdPartyApps",
205 | "Description": "Disables ContentDeliveryManager from installing 3rd party apps. This tweak is activated also in case the system app 'ContentDeliveryManager' is removed from the system apps tab."
206 | },
207 | {
208 | "Name": "ExplorerUIRibbon",
209 | "Label": "Classic Explorer UI ribbon",
210 | "Type": "Switch",
211 | "Binding": "SelectiveRegistry.ExplorerUIRibbon",
212 | "Description": "Add the explorer UI ribbon in Windows 10"
213 | },
214 | {
215 | "Name": "ClassicSearchExplorer",
216 | "Label": "Explorer classic file search",
217 | "Type": "Switch",
218 | "Binding": "SelectiveRegistry.ClassicSearchExplorer",
219 | "Description": "Disables modern UWP explorer file search"
220 | },
221 | {
222 | "Name": "RemoveTaskbarPinnedIcons",
223 | "Label": "Remove taskbar pinned icons",
224 | "Type": "Switch",
225 | "Binding": "SelectiveRegistry.RemoveTaskbarPinnedIcons",
226 | "Description": "Removes taskbar pinned icons"
227 | },
228 | {
229 | "Name": "DisableTeamsApp",
230 | "Label": "Remove Microsoft Teams App",
231 | "Type": "Switch",
232 | "Binding": "SelectiveRegistry.DisableTeamsApp",
233 | "Description": "Removes Microsoft Teams App"
234 | },
235 | {
236 | "Name": "RunAsTiContextMenu",
237 | "Label": "Add Run As Trusted Installer context menu entry",
238 | "Type": "Switch",
239 | "Binding": "SelectiveRegistry.RunAsTiContextMenu",
240 | "Description": "Add Run As Trusted Installer context menu entry"
241 | }
242 | ]
243 | },
244 | "Specific": {
245 | "Label": "Specific",
246 | "Column": 1,
247 | "Controls": [
248 | {
249 | "Name": "W11ClassicContextMenu",
250 | "Label": "W11 Classic context menus",
251 | "Type": "Switch",
252 | "Binding": "SelectiveRegistry.W11ClassicContextMenu",
253 | "Description": "Makes context menus classic looking, as in W10",
254 | "Restrictions": [
255 | {
256 | "Build": "22000",
257 | "Criteria": "min"
258 | }
259 | ]
260 | },
261 | {
262 | "Name": "DisableVirtualizationSecurity",
263 | "Label": "W11 Disable Virtualization Security",
264 | "Type": "Switch",
265 | "Binding": "SelectiveRegistry.DisableVirtualizationSecurity",
266 | "Description": "Disables Core integrity and Virtualization based security (builds >= 22000)",
267 | "Restrictions": [
268 | {
269 | "Build": "22000",
270 | "Criteria": "min"
271 | }
272 | ]
273 | },
274 | {
275 | "Name": "AmoledBlackTheme",
276 | "Label": "W11 Add AMOLED Black Theme",
277 | "Type": "Switch",
278 | "Binding": "SelectiveRegistry.AmoledBlackTheme",
279 | "Description": "W11 Add AMOLED Black Theme",
280 | "Restrictions": [
281 | {
282 | "Build": "22000",
283 | "Criteria": "min"
284 | }
285 | ]
286 | }
287 | ]
288 | }
289 | }
290 |
--------------------------------------------------------------------------------