掌握Windows 11精简艺术:Tiny11Builder实战手册
【免费下载链接】tiny11builderScripts to build a trimmed-down Windows 11 image.项目地址: https://gitcode.com/GitHub_Trending/ti/tiny11builder
你是否曾因Windows 11的臃肿而烦恼?老旧设备运行缓慢,虚拟机磁盘空间告急,开发环境搭建耗时费力。Tiny11Builder正是解决这些痛点的专业工具,它通过PowerShell脚本自动化移除Windows 11中的冗余组件,生成极致轻量的系统镜像。这个开源项目让技术爱好者和开发者能够轻松定制属于自己的高效Windows系统,实现性能与功能的完美平衡。
🔥 三维价值解析:为何选择Tiny11Builder
性能维度:老旧设备的重生秘钥
对于内存仅4GB、使用机械硬盘的老旧电脑,原生Windows 11启动需要180秒,内存占用高达3.2GB。Tiny11Builder通过精准移除20多个非必要应用,将启动时间压缩至90秒内,内存占用降至1.8GB,让2015年前后的设备重获新生。
效率维度:虚拟化环境的空间优化师
在虚拟化部署中,每个GB的磁盘空间都至关重要。标准版tiny11maker.ps1将ISO体积从15GB压缩至8GB,而核心版tiny11Coremaker.ps1更是极致压缩至6GB,虚拟机启动时间缩短至45秒,实现高密度部署。
定制维度:开发者的纯净工作台
开发者需要纯净的测试环境,但传统安装耗时费力。Tiny11Builder提供一键生成轻量系统,配合内置的autounattend.xml无人值守配置文件,5分钟内即可获得干净的开发环境,大幅提升测试效率。
🛠️ 实战操作指南:三步完成系统精简
第一步:环境准备与基础配置
开始前,你需要准备以下资源:
- Windows 11官方ISO镜像(从Microsoft官网下载)
- Windows ADK工具包(包含oscdimg.exe)
- 至少20GB的临时磁盘空间
# 设置PowerShell执行策略(仅当前会话有效) Set-ExecutionPolicy Bypass -Scope Process # 验证DISM工具可用性 dism /online /get-features | Select-String "State" # 检查磁盘空间 Get-PSDrive -Name C | Select-Object Used, Free第二步:脚本选择与参数配置
Tiny11Builder提供两个主要版本,根据需求选择:
| 版本类型 | 脚本文件 | 适用场景 | 可维护性 | 移除组件 |
|---|---|---|---|---|
| 标准版 | tiny11maker.ps1 | 日常使用、办公环境 | 支持更新、语言包 | 娱乐应用、广告推送 |
| 核心版 | tiny11Coremaker.ps1 | 测试环境、虚拟机 | 不可更新 | 所有非核心组件 |
# 标准版执行示例 .\tiny11maker.ps1 -ISO E -SCRATCH D # 核心版执行示例 .\tiny11Coremaker.ps1 -ISO E -SCRATCH D第三步:自动化构建与验证
脚本执行后,系统将自动完成以下流程:
- 镜像挂载:自动识别ISO中的Windows版本
- 组件分析:扫描并标记可移除的应用和功能
- 精简处理:使用DISM工具移除选定组件
- 压缩优化:应用恢复压缩技术减少体积
- ISO生成:使用oscdimg创建可启动镜像
# 构建过程监控脚本 $ProgressLog = @{ "Stage" = "Building" "StartTime" = Get-Date "ComponentsRemoved" = 0 "DiskSpaceSaved" = 0 } # 实时监控构建进度 while ($true) { $currentSize = (Get-Item "tiny11.iso" -ErrorAction SilentlyContinue).Length / 1GB if ($currentSize -gt 0) { Write-Host "镜像构建进度: $([math]::Round($currentSize, 2)) GB" -ForegroundColor Yellow break } Start-Sleep -Seconds 30 }🚀 进阶定制技巧:深度优化配置
自定义组件移除策略
编辑tiny11maker.ps1文件,找到$AppsToRemove数组,按需调整移除列表:
# 自定义应用移除配置(编辑tiny11maker.ps1) $CustomAppsToRemove = @( # 娱乐类应用(按需移除) "Clipchamp.Clipchamp", "Microsoft.XboxGameOverlay", "Microsoft.Xbox.TCUI", # 广告推送应用 "Microsoft.BingNews", "Microsoft.BingWeather", "Microsoft.BingFinance", # 办公工具(选择性保留) # "Microsoft.Office.OneNote", # 注释掉表示保留 "Microsoft.PowerAutomateDesktop", # 系统工具 "Microsoft.GetHelp", "Microsoft.GetStarted", "Microsoft.People" ) # 系统功能移除配置 $FeaturesToRemove = @( "WindowsMediaPlayer", # Windows媒体播放器 "Printing-XPSServices", # XPS打印服务 "Internet-Explorer-Optional-amd64", # IE浏览器 "MediaPlayback" # 媒体播放功能 )无人值守安装深度定制
修改autounattend.xml文件,实现完全自动化安装配置:
<!-- 深度定制无人值守配置 --> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <OOBE> <HideEULAPage>true</HideEULAPage> <HideLocalAccountScreen>true</HideLocalAccountScreen> <HideOnlineAccountScreens>true</HideOnlineAccountScreens> <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> <NetworkLocation>Work</NetworkLocation> <ProtectYourPC>1</ProtectYourPC> <SkipUserOOBE>true</SkipUserOOBE> <SkipMachineOOBE>true</SkipMachineOOBE> </OOBE> <UserAccounts> <LocalAccounts> <LocalAccount wcm:action="add"> <Password> <Value>YourSecurePassword123!</Value> <PlainText>true</PlainText> </Password> <Description>Administrator Account</Description> <DisplayName>Administrator</DisplayName> <Group>Administrators</Group> <Name>Administrator</Name> </LocalAccount> </LocalAccounts> </UserAccounts> <AutoLogon> <Enabled>true</Enabled> <Username>Administrator</Username> <Password> <Value>YourSecurePassword123!</Value> <PlainText>true</PlainText> </Password> </AutoLogon> <RegisteredOrganization>YourCompany</RegisteredOrganization> <RegisteredOwner>YourName</RegisteredOwner> <TimeZone>China Standard Time</TimeZone> </component> </settings>性能优化注册表配置
创建性能优化脚本,进一步提升系统响应速度:
# 系统性能优化脚本 $RegistryOptimizations = @{ # 禁用遥测和数据收集 "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" = @{ "AllowTelemetry" = 0 "MaxTelemetryAllowed" = 0 } # 禁用消费者体验 "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" = @{ "DisableWindowsConsumerFeatures" = 1 "DisableSoftLanding" = 1 } # 优化电源设置 "HKLM:\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\54533251-82be-4824-96c1-47b60b740d00\0cc5b647-c1df-4637-891a-dec35c318583" = @{ "Attributes" = 2 } # 禁用Windows搜索索引 "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" = @{ "PreventIndexingOutlook" = 1 "DisableIndexingEncryptedItems" = 1 } } # 应用注册表优化 foreach ($regPath in $RegistryOptimizations.Keys) { if (!(Test-Path $regPath)) { New-Item -Path $regPath -Force | Out-Null } foreach ($value in $RegistryOptimizations[$regPath].GetEnumerator()) { Set-ItemProperty -Path $regPath -Name $value.Key -Value $value.Value -Force } }🔗 生态整合方案:与其他工具无缝协作
与自动化部署工具集成
将Tiny11Builder集成到现有的自动化部署流程中:
# PowerShell DSC配置集成 Configuration Tiny11Deployment { param( [Parameter(Mandatory=$true)] [string]$ISOPath, [Parameter(Mandatory=$true)] [string]$ScratchDrive ) Node $AllNodes.NodeName { Script BuildTiny11 { GetScript = { @{Result = "Tiny11 Builder Status"} } SetScript = { # 下载Windows 11 ISO $isoUrl = "https://software-download.microsoft.com/download/Windows11" Invoke-WebRequest -Uri $isoUrl -OutFile "$env:TEMP\win11.iso" # 挂载ISO Mount-DiskImage -ImagePath "$env:TEMP\win11.iso" # 运行Tiny11Builder Set-Location "C:\Tiny11Builder" .\tiny11maker.ps1 -ISO E -SCRATCH D # 卸载ISO Dismount-DiskImage -ImagePath "$env:TEMP\win11.iso" } TestScript = { Test-Path "C:\Tiny11Builder\tiny11.iso" } } } }与虚拟化平台结合
为VMware、VirtualBox等虚拟化平台创建优化模板:
# VMware虚拟机模板创建脚本 function Create-Tiny11VMTemplate { param( [string]$TemplateName = "Tiny11-Template", [int]$MemoryMB = 2048, [int]$DiskSizeGB = 20 ) # 创建虚拟机配置 $vmConfig = @{ Name = $TemplateName MemoryStartupBytes = $MemoryMB * 1MB NewVHDPath = "C:\VMs\$TemplateName.vhdx" NewVHDSizeBytes = $DiskSizeGB * 1GB Generation = 2 BootDevice = "VHD" } # 创建虚拟机 New-VM @vmConfig # 挂载Tiny11 ISO Set-VMDvdDrive -VMName $TemplateName -Path "C:\Tiny11Builder\tiny11.iso" # 配置虚拟机设置 Set-VMProcessor -VMName $TemplateName -Count 2 Set-VMMemory -VMName $TemplateName -DynamicMemoryEnabled $true -MinimumBytes 512MB -MaximumBytes 4096MB Write-Host "Tiny11虚拟机模板 '$TemplateName' 创建完成" -ForegroundColor Green }与容器化环境对接
为Docker Windows容器创建轻量基础镜像:
# Docker镜像构建脚本 $DockerfileContent = @' # 基于Tiny11构建Docker镜像 FROM mcr.microsoft.com/windows:ltsc2022 # 复制Tiny11优化配置 COPY ./optimizations/ C:/optimizations/ # 应用性能优化 RUN powershell -Command ` # 禁用不必要的服务 Get-Service | Where-Object {$_.Name -match "DiagTrack|dmwappushservice|WMPNetworkSvc"} | Set-Service -StartupType Disabled # 清理临时文件 Remove-Item -Path "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue # 优化系统设置 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "NtfsDisableLastAccessUpdate" -Value 1 # 设置工作目录 WORKDIR C:/app # 暴露端口 EXPOSE 80 443 '@ $DockerfileContent | Out-File -FilePath "Dockerfile" -Encoding UTF8⚠️ 避坑指南与故障排除
常见问题解决方案
问题1:PowerShell执行策略限制
# 解决方案:临时绕过执行策略 Set-ExecutionPolicy Bypass -Scope Process -Force # 验证执行策略 Get-ExecutionPolicy -Scope Process问题2:DISM操作失败
排查步骤: 1. 检查磁盘空间:确保有25GB以上可用空间 2. 验证Windows ADK安装:运行 "dism /online /get-features" 3. 检查ISO完整性:使用 Get-FileHash 验证文件哈希值 4. 查看详细日志:检查 $PSScriptRoot\dism.log 文件问题3:生成的ISO无法启动
验证流程: 1. 使用虚拟机测试:VMware或VirtualBox加载测试 2. 检查引导文件:确认boot.wim和install.wim存在 3. 验证OSCDIMG版本:确保使用Windows ADK提供的版本 4. 检查无人值守文件:autounattend.xml格式正确问题4:系统功能异常
恢复方案: 标准版问题: 1. 使用DISM添加功能:DISM /Online /Add-Capability 2. 重新安装应用:从Microsoft Store恢复 3. 系统还原点:如果有创建还原点 核心版问题: 1. 重新创建镜像:核心版无法添加功能 2. 使用标准版替代:如需可维护性 3. 手动添加组件:通过DISM离线添加性能监控与基准测试
创建性能监控脚本,量化优化效果:
# 系统性能基准收集函数 function Get-SystemPerformanceBaseline { param( [string]$OutputPath = "$PSScriptRoot\performance_report.json" ) $performanceData = @{ Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" SystemInfo = @{ OSVersion = (Get-CimInstance Win32_OperatingSystem).Version TotalMemory = [math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB, 2) Processor = (Get-CimInstance Win32_Processor).Name } PerformanceMetrics = @{ # 启动时间测试 StartupTime = Measure-Command { Restart-Computer -Force -Wait }.TotalSeconds # 内存使用情况 MemoryUsage = @{ Total = (Get-Process | Measure-Object WorkingSet -Sum).Sum / 1MB Available = (Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory / 1MB Processes = (Get-Process).Count } # 磁盘性能 DiskPerformance = @{ ReadSpeed = (Get-Counter "\PhysicalDisk(*)\Disk Reads/sec").CounterSamples[0].CookedValue WriteSpeed = (Get-Counter "\PhysicalDisk(*)\Disk Writes/sec").CounterSamples[0].CookedValue FreeSpace = [math]::Round((Get-PSDrive C).Free / 1GB, 2) } # 网络延迟 NetworkLatency = Test-Connection -ComputerName "8.8.8.8" -Count 4 | Measure-Object -Property ResponseTime -Average | Select-Object -ExpandProperty Average } ServicesStatus = @{ Running = (Get-Service | Where-Object {$_.Status -eq 'Running'}).Count Stopped = (Get-Service | Where-Object {$_.Status -eq 'Stopped'}).Count Disabled = (Get-Service | Where-Object {$_.StartType -eq 'Disabled'}).Count } } # 保存性能报告 $performanceData | ConvertTo-Json -Depth 5 | Out-File -FilePath $OutputPath -Encoding UTF8 return $performanceData } # 对比优化前后效果 $before = Get-Content "original_performance.json" | ConvertFrom-Json $after = Get-SystemPerformanceBaseline Write-Host "=== 优化效果对比 ===" -ForegroundColor Green Write-Host "启动时间: $([math]::Round($before.PerformanceMetrics.StartupTime, 2))s → $([math]::Round($after.PerformanceMetrics.StartupTime, 2))s" -ForegroundColor Cyan Write-Host "内存占用: $([math]::Round($before.PerformanceMetrics.MemoryUsage.Total, 2))MB → $([math]::Round($after.PerformanceMetrics.MemoryUsage.Total, 2))MB" -ForegroundColor Cyan Write-Host "磁盘空间: $([math]::Round($before.PerformanceMetrics.DiskPerformance.FreeSpace, 2))GB → $([math]::Round($after.PerformanceMetrics.DiskPerformance.FreeSpace, 2))GB" -ForegroundColor Cyan Write-Host "运行服务: $($before.ServicesStatus.Running)个 → $($after.ServicesStatus.Running)个" -ForegroundColor Cyan🔮 未来展望与社区参与
项目发展方向
Tiny11Builder作为持续演进的开源项目,未来将重点关注以下方向:
技术增强计划
- 智能组件检测:基于机器学习识别可安全移除的组件
- 模块化架构:支持插件式扩展,便于社区贡献
- 图形界面:开发直观的GUI工具,降低使用门槛
- 云端集成:支持从云端仓库获取优化配置模板
社区协作模式
- 问题反馈机制:在项目仓库提交详细的Issue报告
- 功能建议流程:通过Pull Request贡献代码改进
- 文档完善计划:鼓励用户补充使用案例和故障排除指南
- 配置模板共享:建立社区优化配置库
参与贡献指南
想要为Tiny11Builder贡献代码?遵循以下最佳实践:
# 开发环境设置 # 1. 克隆仓库 git clone https://gitcode.com/GitHub_Trending/ti/tiny11builder # 2. 创建功能分支 git checkout -b feature/new-optimization # 3. 代码规范检查 # PowerShell脚本应遵循PSScriptAnalyzer规范 Invoke-ScriptAnalyzer -Path .\tiny11maker.ps1 # 4. 测试修改效果 # 创建测试环境 New-Item -Path "C:\TestTiny11" -ItemType Directory Copy-Item .\tiny11maker.ps1 -Destination "C:\TestTiny11" # 5. 提交变更 git add . git commit -m "feat: 添加新的性能优化选项" git push origin feature/new-optimization版本管理与发布流程
# 版本发布检查清单 $ReleaseChecklist = @{ "代码质量" = @( "通过PSScriptAnalyzer检查", "无语法错误", "添加适当的错误处理" ) "功能测试" = @( "标准版脚本测试通过", "核心版脚本测试通过", "无人值守安装验证", "多语言支持测试" ) "文档更新" = @( "更新README.md", "添加变更日志", "更新使用示例" ) "发布准备" = @( "版本号更新", "创建发布标签", "生成预编译版本" ) } # 自动化发布脚本 function Publish-Tiny11Release { param( [string]$Version, [string]$ReleaseNotes ) # 验证版本号格式 if ($Version -notmatch '^\d+\.\d+\.\d+$') { throw "版本号格式错误,应为 x.y.z 格式" } # 创建发布包 $releaseFiles = @( "tiny11maker.ps1", "tiny11Coremaker.ps1", "autounattend.xml", "README.md", "LICENSE" ) $releaseDir = "Tiny11Builder-v$Version" New-Item -Path $releaseDir -ItemType Directory -Force foreach ($file in $releaseFiles) { Copy-Item -Path $file -Destination "$releaseDir\" -Force } # 创建ZIP包 Compress-Archive -Path "$releaseDir\*" -DestinationPath "Tiny11Builder-v$Version.zip" -Force Write-Host "版本 $Version 发布包创建完成" -ForegroundColor Green }📋 实施检查清单:确保成功部署
准备工作确认
- 确认硬件满足Windows 11最低要求(TPM 2.0、Secure Boot等)
- 准备至少25GB临时磁盘空间用于镜像处理
- 下载官方Windows 11 ISO镜像(版本22H2或更新)
- 安装Windows ADK工具包(包含必要的DISM和OSCDIMG工具)
- 备份重要数据和现有系统镜像
- 确保稳定的网络连接(如需下载额外组件)
脚本执行验证
- 以管理员身份运行PowerShell 5.1或更高版本
- 设置正确的执行策略:Set-ExecutionPolicy Bypass -Scope Process
- 成功挂载Windows 11 ISO镜像到指定驱动器
- 根据需求选择合适版本:标准版(可维护)或核心版(极致精简)
- 指定正确的驱动器和临时目录参数
优化效果验证
- 测试系统启动时间(目标:标准版<90秒,核心版<45秒)
- 检查磁盘空间占用(目标:标准版<10GB,核心版<6GB)
- 验证内存使用情况(空闲时目标:<2GB)
- 测试关键功能:网络连接、音频输出、显示设置
- 验证应用程序兼容性(常用软件运行正常)
- 检查系统更新功能(仅标准版)
部署前最终确认
- 创建系统备份或虚拟机快照
- 记录所有优化配置参数和自定义设置
- 准备应急恢复方案和回滚计划
- 测试网络功能和必要的外部连接
- 验证安全设置和防火墙规则
- 确认用户账户和权限配置正确
通过遵循这份完整的Tiny11Builder实战手册,你将能够掌握Windows 11系统精简的核心技术,为各种应用场景创建高效、稳定的轻量级Windows环境。无论是老旧设备优化、虚拟化部署还是开发测试环境搭建,Tiny11Builder都能提供专业级的解决方案。
【免费下载链接】tiny11builderScripts to build a trimmed-down Windows 11 image.项目地址: https://gitcode.com/GitHub_Trending/ti/tiny11builder
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考