我正在尝试转换一个 PowerShell 命令,该命令生成当前安装在 Python 设备上的应用程序列表,以在应用程序卸载程序中使用该列表。
我正在使用的命令是:
Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall* |
Select-Object DisplayName, DisplayVersion, UninstallString
尝试转换命令时出现错误:
'Select-Object' 不是内部或外部命令、可运行程序或批处理文件。
我的示例 Python 代码如下:
shell = "powershell.exe "
shell_command = "Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall*"
followup_command = "Select-Object DisplayName, DisplayVersion, UninstallString"
result = subprocess.run(
shell + shell_command + " | " + followup_command,
encoding="UTF-8",
stdout=subprocess.PIPE,
)
result = result.stdout
print(result)
我哪里错了?