我尝试通过 PowerShell 卸载常规程序,但我尝试放入 name="program name"
部分的所有内容似乎都失败了。
我关注了this guide here关于如何做到这一点。
我尝试删除 Google Chrome 作为我的测试示例。它实际上并不是我想要删除的,只是一个我可以轻松快速地重新安装的测试目标。
我首先在另一台装有 Google Chrome 的机器上进行了测试,但没有出现在这个列表中。也出现了这个错误。但现在我在我的主机上进行了测试,Google Chrome 确实出现在列表中。
PS C:\WINDOWS\system32> wmic product get name Name
Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219
Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219
Microsoft Visual Studio 2010 Tools for Office Runtime (x64)
Google Chrome
Google Update Helper
Microsoft SQL Server 2008 Native Client
PS C:\WINDOWS\system32> wmic product where name="Google Chrome" call uninstall
ERROR:
Description = Invalid query
一些不相关的产品获取名称
条目已被删除,以保持列表简短。
我希望 WMIC 卸载该程序,但我收到了上面发现的错误。
最佳答案
WMIC 命令需要引号内的过滤器:wmic Product where "name='Google Chrome'"
Powershell 还公开了具有更清晰语法的 Get-WMIObject cmdlet(别名 gwmi
):
$chrome = gwmi win32_product -filter "name='Google Chrome'"
$chrome.Uninstall
关于powershell - 为什么在尝试卸载时 WMIC 给出无效查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57151712/