我已经使用 Zotero 安装了winget install Zotero.Zotero,它在C:\Program Files (x86)\Zotero. 但是当我运行时winget upgrade,它显示了两个 Zotero 版本,如下所示:
Name Id Version Available Source
---------------------------------------------
Zotero Zotero.Zotero 6.0.10 6.0.13 winget
Zotero Zotero.Zotero 6.0.9 6.0.13 winget
2 upgrades available.
Run Code Online (Sandbox Code Playgroud)
我已经验证当前安装的 Zotero 版本是6.0.13. 由于我之前安装过带或不带 winget 的 Zotero,我认为这些条目可能反映了这些安装。因此,我想卸载/删除这些而不删除6.0.13当前安装的版本C:\Program Files (x86)\Zotero。
我的问题是,如何让winget显示这两个版本的安装目录,以便我可以手动删除它们?
Joh*_*van 18
看来 winget 版本v1.5.1081-preview及以上版本(包括PR3128),通过运行 包含默认目录的信息winget --info。
还有一个悬而未决的问题,即能够列出每个应用程序的目录(Issue 2298)。
关于 Zotero 本身,我找不到带有 ID 的包Zotero.Zotero,但确实找到了DigitalScholar.Zotero。这表明使用了默认安装程序,因此默认路径将与应用程序的路径相同(通过搜索他们的文档,这似乎是C:\Program Files (x86)\Zotero,尽管我没有看到任何明确的内容)。
注意:磁盘上可能Zotero.Zotero不存在您的附加版本;但仅存在于WinGet 的数据库中(例如,如果安装了它,则路径会在WinGet 不知情的情况下被删除)。有关如何查询该数据库的信息,请参阅“尝试查找元数据失败”。
确切的位置取决于软件包,据我所知,目前无法获取所有已安装的 winget 软件包的信息。
对于那些没有安装程序而只是下载文件的人,它们被放置在以下文件夹下:%localappdata%\microsoft\winget\packages
如果存在带有可移植命令别名的 exe(即,为了避免将每个 exe 的路径添加到 PATH 变量),则会创建符号链接。该符号链接保存在 %localappdata%\Microsoft\WinGet\Links\.
注意:某些应用程序的清单可能会指定默认安装目录。这是在他们的InstallLocation属性中给出的(参见schema)。
我想知道您是否可以找到 WinGet 存储已安装软件包的元数据的路径...我找不到 - 但请注意下面的内容,以防其他人更深入地寻找(我的结论是 WinGet 不记得它安装的东西的位置,只是它已经安装了它们/安装了什么版本;其他一切都留给默认安装程序)。
您可以通过运行winget settings然后查看打开的文件的路径来获取其设置settings.json文件的路径。对我来说这是:C:\Users\myUsername\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
通过在该目录中查找,我发现了一个 SQLLite DB: C:\Users\myUsername\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Microsoft.Winget.Source_8wekyb3d8bbwe\installed.db。
我们可以使用以下 PowerShell 查询该文件/数据库:
# Load the System.Data.SQLite.dll assembly. This is likely already somewhere on your machine, but if you can't find it, see https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
Add-Type -Path 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\PrivateAssemblies\System.Data.SQLite.dll'
# Update this path with your install.db path
$installDbPath = 'C:\Users\myUsername\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Microsoft.Winget.Source_8wekyb3d8bbwe\installed.db'
# create a connection to this db
$con = [System.Data.SQLite.SQLiteConnection]::new("Data Source=$installDbPath")
$con.Open()
# Create and execute a query to list all tables (thanks to /sf/answers/1023673521/ for the SQL)
$command = $con.CreateCommand()
$command.CommandText = @"
SELECT name FROM sqlite_master
WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%'
UNION ALL
SELECT name FROM sqlite_temp_master
WHERE type IN ('table','view')
ORDER BY 1;
"@
$data = [System.Data.DataSet]::new()
$adapter = [System.Data.SQLite.SQLiteDataAdapter]::new($command)
$adapter.Fill($data) | Out-Null
$data.Tables.Rows
# channels
# commands
# commands_map
# ids
# manifest
# manifest_metadata
# metadata
# monikers
# names
# norm_names
# norm_names_map
# norm_publishers
# norm_publishers_map
# pathparts
# pfns
# pfns_map
# productcodes
# productcodes_map
# tags
# tags_map
# versions
# Now repeat over the IDs table to give the IDs of all installed packages
$command.CommandText = "SELECT * FROM ids"
$data = [System.Data.DataSet]::new() # reset this to avoid appending
$adapter.Fill($data) #note: adapter has a reference to $command, so by updating the command text the adapter's command is automatically updated
$data.Tables.Rows | ft -AutoSize
# sadly I hunted through all the other tables but couldn't find any hint of an installation directory being stored here
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21489 次 |
| 最近记录: |