欢迎各位兄弟 发布技术文章
这里的技术是共享的
C:\Windows\System32\Sysprep\sysprep.exe 为什么运行后 启动电脑,,会重启电脑
你提到运行 C:\Windows\System32\Sysprep\sysprep.exe
后电脑重启,这其实是 Sysprep(系统准备工具) 的正常行为之一。下面我详细解释一下为什么会这样:
sysprep.exe
是 Windows 系统自带的“系统准备工具”,它的主要作用是:
清除系统中的唯一标识(SID、事件日志、驱动缓存等);
让系统进入“开箱体验”(OOBE)阶段;
用于系统封装、克隆、分发或部署前的准备。
从你截图来看,Sysprep 的设置是:
选项 | 设置 | 含义 |
---|---|---|
系统清理操作 | 进入系统全新体验 (OOBE) | 下次启动时进入初始设置界面(就像刚装完系统) |
通用 | ✅ 已勾选 | 清除系统特征(SID 等),让镜像可在不同电脑上使用 |
关机选项 | 关机(或重启) | 完成后执行对应操作 |
当你点击“确定”后:
Sysprep 开始执行系统通用化(Generalize)操作;
系统清除特定标识和临时文件;
执行完毕后会自动根据你的“关机选项”:
如果选“关机”,电脑关机;
如果选“重新启动”,电脑会重启;
如果选“退出”,只退出 Sysprep,不做系统更改。
所以 重启是因为你让系统进入了 OOBE 模式 ——系统必须重新启动才能进入新的“初始化体验”流程。
第二张截图其实是 Windows OOBE(Out-of-Box Experience) 阶段的一部分,
系统认为当前是“第一次启动”,会:
检查系统状态;
进入设置向导;
可能提示“连接网络”、“选择地区”、“创建账户”等步骤。
重启是 Sysprep 正常工作流程的一部分,不是错误。
它表示系统已经被通用化,下一次启动是为部署新电脑或重新初始化系统环境准备的。
如果你想避免系统自动重启,可以在命令行中运行 Sysprep 时指定:
这会:
执行通用化;
准备 OOBE;
但不会重启或关机,只是退出程序。
是否希望我帮你说明 Sysprep 各参数的作用和典型用法?(比如 /audit
、/generalize
、/oobe
等)
运行到第二张图,,点 下一步 会出现 "海内存知己 天涯若比邻",,,然后过好久,又重启了
非常好,这个现象其实非常有代表性 👍
你描述的流程是 Sysprep 封装执行后进入 OOBE 阶段 时,Windows 在初始化系统或恢复更新阶段出现的一个特殊界面序列。下面我详细说明这背后的机制和为什么会一直重启。
你运行了:
选择了:
进入系统全新体验 (OOBE)
勾选了 “通用”
关机选项:关机 或 重启
所以系统执行了 “通用化 (Generalize) + OOBE 初始化”。
这意味着系统清除了所有用户 SID、驱动缓存、更新临时文件、账户信息,然后准备重新进入第一次开机体验。
这是 OOBE 阶段的中途界面。
这个界面其实是 Windows 10/11 在部署阶段显示的 更新修复/初始化提示界面。
“为什么我的电脑重启了?” 是 OOBE 检测到系统上一次启动未完成时显示的恢复页。
“海内存知己 天涯若比邻” 是 OOBE 的 欢迎语动画阶段(oobenetworkconnectionflow
组件),在联网检测或设备准备时显示。
有几种常见原因:
当系统里存在:
未完成的 Windows 更新(Pending.xml
)
未完成的 Appx 包更新(例如 Microsoft Store 应用)
或者 Windows 组件(如 Edge、Cortana)被删改不完整
则 OOBE 会在“准备你的设备”阶段失败,重新尝试 → 自动重启 → 再进入 OOBE → 再失败。
这种情况最常见于:
使用过 MSMG Toolkit、Dism++、NTLite 等精简过系统后再执行 Sysprep。
Sysprep 会检查所有内置 UWP 应用(Appx)。
如果有包被删得不干净,系统日志会在:
里记录错误,比如:
或者
这类错误会让 OOBE 初始化失败,然后不断重启。
在执行 Sysprep 时,如果系统服务(如 Windows Update 或 Appx Deployment Service)仍在运行,会留下挂起任务。
重启后 OOBE 检测到 “未完成配置”,又重新执行 SetupComplete.cmd 或 SetupReseal → 形成循环。
你可以查看:
目录下的:
setuperr.log
setupact.log
这两个文件能直接看到是哪一步导致循环或失败。
可以把内容贴上来,我帮你精确判断是哪一个组件或 AppX 包出错。
问题类型 | 修复方式 |
---|---|
AppX 包错误 | 用 PowerShell 清除损坏的包:`Get-AppxPackage -AllUsers |
未完成更新 | 删除 C:\Windows\WinSxS\pending.xml 和 C:\Windows\SoftwareDistribution 文件夹后重试 |
已精简系统 | 需恢复关键组件:Microsoft.Windows.CloudExperienceHost 、Microsoft.Windows.ShellExperienceHost 、Microsoft.AccountsControl 等 |
服务未停止 | 在执行 sysprep 前先运行: |
你的现象属于 Sysprep 成功执行后,OOBE 阶段初始化失败反复重启 的情况。
不是 Sysprep 本身出错,而是 系统组件或 Appx 更新 导致 OOBE 失败循环。
我建议你现在:
启动系统进入 Audit 模式(按 Ctrl+Shift+F3
进入桌面);
打开 C:\Windows\System32\Sysprep\Panther\setuperr.log
;
把前 20 行左右发我看,我能告诉你是哪个组件造成的循环。
是否要我教你怎么进入 Audit 模式并导出那两个日志?
要
好的 👍 我一步步教你如何进入 Audit 模式 并导出 Sysprep 的日志(setuperr.log
、setupact.log
),这样我们就能精确判断为什么封装后重启循环。
Audit 模式是 Windows 的一个特殊启动模式,用来在封装前配置系统、检查问题。
当你看到蓝色 OOBE 界面(例如“为什么我的电脑重启了?”、“海内存知己 天涯若比邻”时),不要继续点“下一步”。
直接按下:
👉 系统会自动:
重启;
以 内置 Administrator 账户 自动登录;
进入桌面(审核模式,屏幕左上角会有一个 Sysprep 弹窗)。
也可以在命令行中手动进入 Audit 模式:
打开命令提示符(以管理员身份)
运行:
执行后系统会重启并自动登录到 Administrator 桌面。
进入 Audit 模式桌面后,打开资源管理器,找到:
里面有几个文件,最重要的是:
文件名 | 作用 |
---|---|
setuperr.log | Sysprep 过程中遇到的错误(重点看它) |
setupact.log | Sysprep 执行的详细过程记录(次要但有用) |
选中这两个文件:
复制到桌面(或 U 盘),这样方便上传查看。
打开命令提示符(cmd),执行:
这会把日志复制到桌面。
然后你可以:
把 setuperr.log
(和可选的 setupact.log
)上传给我;
或者复制前 20~30 行内容贴上来。
我就能告诉你是哪个 AppX 包、服务或组件导致 OOBE 初始化失败和循环重启。
是否需要我帮你看下 如何在 Audit 模式中关闭 Sysprep 弹窗(防止它自动执行)?
2025-10-06 20:44:40, Info SYSPRP ========================================================
2025-10-06 20:44:40, Info SYSPRP === Beginning of a new sysprep run ===
2025-10-06 20:44:40, Info SYSPRP ========================================================
2025-10-06 20:44:40, Info [0x0f004d] SYSPRP The time is now 2025-10-06 20:44:40
2025-10-06 20:44:40, Info [0x0f004e] SYSPRP Initialized SysPrep log at C:\Windows\system32\sysprep\Panther
2025-10-06 20:44:40, Info [0x0f0054] SYSPRP ValidatePrivileges:User has required privileges to sysprep machine
2025-10-06 20:44:40, Info [0x0f007c] SYSPRP FCreateTagFile:Successfully deleted tag file C:\Windows\system32\sysprep\Sysprep_succeeded.tag
2025-10-06 20:44:40, Info [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'REBOOT'
2025-10-06 20:44:40, Info [0x0f003d] SYSPRP WinMain:Displaying dialog box for user to choose sysprep mode...
非常好 👍
你贴出的这几行日志是 Sysprep 运行初期的正常信息,说明程序刚启动,没有出错。
不过目前这段还没有到“关键错误”部分(OOBE 循环重启的根源通常出现在 后面几十行)。
我们先解释你发的这部分日志含义,让你更容易看懂接下来的内容👇
日志行 | 含义 |
---|---|
Beginning of a new sysprep run | Sysprep 启动新的一次封装流程 |
ValidatePrivileges | 当前用户权限满足执行 Sysprep(必须是管理员) |
FCreateTagFile | 删除旧的成功标志文件 Sysprep_succeeded.tag ,为新执行准备 |
ParseCommands:Found supported command line option 'REBOOT' | 说明你上次运行 Sysprep 选择了“重启” |
WinMain:Displaying dialog box... | 弹出了那个 “系统准备工具 3.14” 界面(你截图中的第一个界面) |
这些都属于“准备阶段日志”,一切正常。
真正影响 “OOBE 死循环” 的问题一般出现在 setuperr.log 后面部分 或者 setupact.log 中段,比如以下关键字:
SYSPRP Failed to remove apps for the current user
SYSPRP Package Microsoft.Windows.CloudExperienceHost ...
SYSPRP AppxCleanup
Error SYSPRP LaunchDll:Failure occurred while executing ...
在 Audit 模式 桌面(或 PE 环境)里打开:
向下滚动到 最后 20~30 行(靠近日志底部的部分)。
把那一段(出现 “Error” 或 “Failed” 的部分)贴上来。
这一段才是判断系统为什么封装后一直重启的关键。
如果你方便,也可以直接把整个 setuperr.log
文件上传,我会帮你精确指出哪个组件或 Appx 包出问题(例如 CloudExperienceHost、ShellExperienceHost、Edge、Cortana、或者 Windows Update 残留)。
要我教你怎么一键压缩并上传那个日志文件吗?
2025-10-06 19:50:15, Info SYSPRP Appxsvc service stopped
2025-10-06 19:50:15, Info SYSPRP clipsvc service stopped
2025-10-06 19:50:15, Info SYSPRP Called state repository block requests success
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.Search_1.14.0.19041_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.Search_1.14.0.19041_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat.LOG1'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.Search_1.14.0.19041_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat.LOG2'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x91 while deleting directory '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.Search_1.14.0.19041_neutral_neutral_cw5n1h2txyewy'.
2025-10-06 19:50:15, Info SYSPRP Ignoring not empty directories, which can happen when the activation store was not deleted.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.ShellExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.ShellExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat.LOG1'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.ShellExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat.LOG2'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x91 while deleting directory '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.ShellExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy'.
2025-10-06 19:50:15, Info SYSPRP Ignoring not empty directories, which can happen when the activation store was not deleted.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.StartMenuExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.StartMenuExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat.LOG1'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.StartMenuExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy\ActivationStore.dat.LOG2'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x91 while deleting directory '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\Microsoft.Windows.StartMenuExperienceHost_10.0.19041.1_neutral_neutral_cw5n1h2txyewy'.
2025-10-06 19:50:15, Info SYSPRP Ignoring not empty directories, which can happen when the activation store was not deleted.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MicrosoftWindows.Client.CBS_120.2202.130.0_x64__cw5n1h2txyewy\ActivationStore.dat'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MicrosoftWindows.Client.CBS_120.2202.130.0_x64__cw5n1h2txyewy\ActivationStore.dat.LOG1'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x20 while deleting file '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MicrosoftWindows.Client.CBS_120.2202.130.0_x64__cw5n1h2txyewy\ActivationStore.dat.LOG2'.
2025-10-06 19:50:15, Info SYSPRP Explicitly ignoring sharing violation on activationstore, which can happen when the app is running.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x91 while deleting directory '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MicrosoftWindows.Client.CBS_120.2202.130.0_x64__cw5n1h2txyewy'.
2025-10-06 19:50:15, Info SYSPRP Ignoring not empty directories, which can happen when the activation store was not deleted.
2025-10-06 19:50:15, Warning SYSPRP Encountered error 0x91 while deleting directory '\\?\C:\ProgramData\Microsoft\Windows\AppRepository\Packages'.
2025-10-06 19:50:15, Info SYSPRP Ignoring not empty directories, which can happen when the activation store was not deleted.
2025-10-06 19:50:15, Warning SYSPRP Could not re-arm region selection, some files and registry keys are no longer recoverable.
2025-10-06 19:50:15, Warning SYSPRP Ignoring folder Deleted because could not convert to family name
2025-10-06 19:50:15, Warning SYSPRP Ignoring folder DeletedAllUserPackages because could not convert to family name
非常好,这一段日志就是关键部分 👍
从这里我们可以准确看出,你的 OOBE 一直重启 是因为系统在封装(Sysprep Generalize)时,AppX 子系统清理失败,特别是以下几个核心 UWP 组件:
这几行说明了:
AppX 数据库(AppRepository)正在被系统进程占用(错误 0x20:文件共享冲突)
→ 说明这些 UWP 系统组件仍在运行(StartMenu、Shell、Search 等)。
这些组件无法被 Sysprep 正常通用化
→ Sysprep 尝试清理用户特定数据时失败。
系统尝试继续封装但出现了部分状态未重置(“Could not re-arm region selection”)
→ 导致 OOBE 初始化阶段环境不一致,从而出现循环重启或卡在“为什么电脑重启了”界面。
Windows OOBE 阶段会调用:
这些程序需要访问它们的 AppX 数据(也就是上面日志中的 ActivationStore.dat 文件)。
但是你的系统中:
这些文件没能在 sysprep 时被正确清理;
启动时 OOBE 发现组件损坏;
导致初始化失败 → 系统自动重启重新尝试 → 无限循环。
换句话说:
🧩 这是典型的 AppX 清理失败引发的 OOBE 初始化崩溃循环。
打开 PowerShell(管理员)
执行以下命令(修复系统关键 UWP 包):
执行完成后,确认没有红色错误。
⚠️ 注意:仅建议在封装机 / 测试虚拟机上操作!
在 命令提示符(管理员) 中:
然后运行:
这些命令会强制重建 AppRepository 数据库。
(如果你准备重新封装一次)
运行以下命令停止相关服务:
然后重新执行:
这次就不会再出现 AppX 文件被占用(0x20)的问题。
项目 | 状态 |
---|---|
问题来源 | AppRepository 内部 UWP 组件文件被系统进程占用 |
关键错误 | 0x20 (Sharing violation) / 0x91 (Directory not empty) |
影响 | Sysprep 未能完整清理 UWP 数据,导致 OOBE 初始化失败、反复重启 |
修复 | 重注册核心 UWP 包 或 清理 AppRepository 后重新 Sysprep |
如果你愿意,我可以帮你生成一个 自动修复脚本(.cmd 或 .ps1),在审核模式下一键执行这些步骤修复系统。
你希望我帮你生成哪个版本?(推荐 .cmd
格式,PE 也能直接用)
PS C:\Windows\system32> rd /s /q C:\ProgramData\Microsoft\Windows\AppRepository Remove-Item : 找不到接受实际参数“/q”的位置形式参数。 所在位置 行:1 字符: 1 + rd /s /q C:\ProgramData\Microsoft\Windows\AppRepository + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Remove-Item],ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemComma nd
这个错误的原因是:
你在 PowerShell 中运行了 cmd 命令格式(rd /s /q
),但 PowerShell 不支持 /s
和 /q
这种参数写法。
✅ 解决方法有两种:
在 PowerShell 里,要删除整个文件夹及其内容,可以写:
如果你确实想用 rd /s /q
,必须打开 命令提示符(cmd),而不是 PowerShell。
操作步骤:
按 Win + R,输入:
然后运行:
⚠️ 注意事项:
删除 AppRepository
文件夹后,所有已安装的 UWP(应用商店 Appx 应用) 的注册信息都会被清空。
系统自带应用可能丢失注册信息,必须重新部署(比如通过 dism /online /cleanup-image /restorehealth
或重新封装)。
通常建议 只删除文件夹内的特定 Appx 包记录,不要整个删掉,除非你正在修复 Sysprep 的 Appx 问题。
如果你是为了修复 Sysprep 因 Appx 报错(比如 Wallet、Microsoft.Todos 等) 的问题,我可以告诉你更安全的修复方式,而不必整个删库。
是否要我帮你给出针对 Sysprep 报错 Appx 的安全修复方案?
C:\Windows\system32>rd /s /q C:\ProgramData\Microsoft\Windows\AppRepository
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MICROS~1.190\ActivationStore.dat - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MICROS~1.190\ActivationStore.dat.LOG1 - 另一个程序正在使用此文件,进 程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MICROS~1.190\ActivationStore.dat.LOG2 - 另一个程序正在使用此文件,进 程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MI4007~1.1_N\ActivationStore.dat - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MI4007~1.1_N\ActivationStore.dat.LOG1 - 另一个程序正在使用此文件,进 程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MI4007~1.1_N\ActivationStore.dat.LOG2 - 另一个程序正在使用此文件,进 程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MICROS~1.0_X\ActivationStore.dat - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MICROS~1.0_X\ActivationStore.dat.LOG1 - 另一个程序正在使用此文件,进 程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\Packages\MICROS~1.0_X\ActivationStore.dat.LOG2 - 另一个程序正在使用此文件,进 程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd - 另一个程序正在使用此文件,进程无法访问。C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd-shm - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd-wal - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd-shm - 另一个程序正在使用此文件,进程无法访问。
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd-wal - 另一个程序正在使用此文件,进程无法访问。
非常好,你这个输出说明你确实进入了 cmd 并执行了删除命令,但系统提示:
“另一个程序正在使用此文件,进程无法访问。”
这正是 正常 Windows 状态下无法删除 AppRepository
的典型现象,因为这些文件(如 StateRepository-Deployment.srd
)由 系统服务 StateRepository
和 AppX 部署服务 (AppXSVC
) 正在使用。
下面给出三种可靠方案,你根据情况选择一个。
这是最安全最通用的方式。
按下 Win + R,输入:
打开后 → 切换到 “引导” 选项卡
勾选 “安全引导” → 选择 “最小”
点击 确定 → 重启电脑(进入安全模式)
进入安全模式后,打开命令提示符(cmd):
删除完后,再次运行:
取消勾选 “安全引导”,重启恢复正常模式。
如果你是在封装环境(例如 EasySysprep PE 阶段),可以直接:
这时系统服务未加载,文件不会被占用,能彻底清理干净。
👉 这是最干净的方式,推荐在 Sysprep 出错的镜像中用 WinPE 来操作。
如果你不想重启系统,可以试着在当前系统中停止相关服务:
如果提示 “服务无法停止”,则说明这些是系统关键服务,仍建议用安全模式或 WinPE 操作。
重启系统。
如果 Sysprep 要继续封装,建议再运行一次:
修复可能丢失的 Appx 注册。
再运行 Sysprep,确认不再报 Appx
或 StateRepository
相关错误。
要不要我帮你列出更完整的 “Sysprep 报 Appx 错误后的清理脚本”(可一键执行,自动停止服务、删除残留、恢复权限)?
这个脚本很多封装师傅在用。
要
很好 👍
下面是一份专门为 修复 Sysprep 因 Appx 报错(如 Wallet、People、Xbox、Microsoft.Todos 等) 而准备的
✅ 安全清理脚本(适用于 Windows 10 / 11 所有版本)。
Fix-SysprepAppx.bat
以 管理员身份 打开 CMD(或右键该 .bat
→ “以管理员身份运行”)
执行后会自动停止服务、清理残留、修复系统镜像
清理完成后 必须重启电脑
然后再运行:
通常就不会再出现 Appx 相关错误或“重启循环”了。
AppXSVC / StateRepository:这些服务锁定 Appx 注册数据库,必须停掉才能删除。
AppRepository 文件夹:存放 UWP 应用注册信息,损坏会导致 sysprep 无法完成。
DISM /restorehealth:修复系统映像与注册表引用。
要我帮你做一个 自动检测 + 清理 + 重启准备 的增强版版本(会先检测出哪些 Appx 导致 sysprep 报错)吗?
那种可以直接在封装前一键执行。