Bug: CommandNotFoundException for SystemSettingsAdminFlows breaks script on line 1069
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- powershell
调研方向
从 PowerShell 脚本的第 1069 行开始,在 SystemSettingsAdminFlows 不可用时重现该故障。检查 issue 中提到的其他 Get-Command 用法是否存在相同的故障模式。完成的标准是:Edge AI 删除阶段跳过缺失的命令,并在不产生未处理的 CommandNotFoundException 的情况下继续执行。
由索引模型根据 Issue 内容生成。
描述
Title: Script crashes during Edge AI removal: Get-Command SystemSettingsAdminFlows throws CommandNotFoundException (line 1069)
Describe the bug
The script crashes at line 1069 during the Edge AI removal phase with a CommandNotFoundException.
The script checks for SystemSettingsAdminFlows like this:
if (Test-Path (get-command SystemSettingsAdminFlows).Source) {
If SystemSettingsAdminFlows is missing from the system (e.g. it was previously removed or debloated), Get-Command raises an error, and the script stops before Test-Path can evaluate to $false. Most likely the error becomes terminating because of $ErrorActionPreference = 'Stop' set in the script.
Steps to reproduce
- Use a system where
SystemSettingsAdminFlows.exeis missing or unavailable inPATH. - Run the script and proceed to the Edge AI removal phase.
- The script fails at line 1069.
Expected behavior
If SystemSettingsAdminFlows is not found, the script should skip this step and continue.
Actual behavior
The script terminates with an unhandled error.
Error log
get-command : Имя "SystemSettingsAdminFlows" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку.
строка:1069 знак:20
+ if (Test-Path (get-command SystemSettingsAdminFlows).Source) {
+ CategoryInfo : ObjectNotFound: (SystemSettingsAdminFlows:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Suggested fix
Option 1 (minimal): suppress the error and check the result.
$cmd = Get-Command SystemSettingsAdminFlows -CommandType Application -ErrorAction SilentlyContinue
if ($cmd) {
# Proceed with execution
}
Option 2 (most predictable): check the file by its full path, without depending on PATH.
$exe = Join-Path $env:SystemRoot 'System32\SystemSettingsAdminFlows.exe'
if (Test-Path -LiteralPath $exe) {
# Proceed with execution
}
-CommandType Application excludes functions and aliases, whose .Source can be empty or a module name, so the extra Test-Path is not needed in Option 1.
Additional notes
Other Get-Command ...).Source calls elsewhere in the script may have the same problem when a component was already removed. It's worth auditing all Get-Command usages and adding -ErrorAction SilentlyContinue or a full-path check.
Environment
- OS: Windows 11 25h2
- PowerShell: 5.1
- Script version / commit: Latest as of 30.09.2026
- 主要语言
- PowerShell
- 星标
- 13.4k
- 派生
- 470
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
zoicware/RemoveWindowsAI 的其他 Issue
-
enhancement help wanted
难度 2/5 1-3 小时 新手友好度 68/100
zoicware/RemoveWindowsAI#258 · 8 条评论 ·
-
bug
难度 3/5 1-2 天 新手友好度 48/100
zoicware/RemoveWindowsAI#269 · 1 条评论 ·
-
bug
难度 4/5 1-2 天 新手友好度 45/100
zoicware/RemoveWindowsAI#267 · 3 条评论 ·
-
Improve logging function可能重新可做 @zoicware 于 67 天前认领,目前没有进行中的 PR。 未关闭enhancement
zoicware/RemoveWindowsAI#232 · 2 条评论 · 已指派 1 人 ·
-
Windows Update Repair Option可能重新可做 @zoicware 于 235 天前认领,目前没有进行中的 PR。 未关闭documentation leave open
zoicware/RemoveWindowsAI#180 · 8 条评论 · 已指派 1 人 ·
查看 zoicware/RemoveWindowsAI 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
raspberrypi/linux#7718 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
sameerasw/essentials#1579 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
easy enhancement help wanted
难度 2/5 1-3 小时 新手友好度 79/100
lacs-project/sysknife#682 · 1 条评论 ·
维护者通常 2 天内回复