【发布时间】:2026-01-13 17:30:01
【问题描述】:
Powershell 输出字符串而不是执行命令。
$apps = @()
$apps += Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" # 32 Bit
$apps += Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
$apps365 = $apps | Where-Object {$_.DisplayName -Match "365" | Sort-Object DisplayName}
$uninPaths = @()
foreach ($item in $apps365) {
$uninPaths += "& CMD /C "+$item.UninstallString
}
Invoke-Command -ScriptBlock{$uninPaths}
【问题讨论】:
-
是什么让您相信卸载字符串需要在
cmd.exe中运行?通常 unistall 字符串是一个标准的可执行文件,它通常接受一个或多个参数/参数。它们不需要在那个特定的 CLI 界面中执行。为什么不直接在您已经在使用的 PowerShell CLI 界面中尝试呢?
标签: powershell cmd command-line