简体   繁体   English

如何获取已安装应用程序的基本父文件夹?

[英]How do I get the base parent folder of an installed application?

For example, ClamWin.exe is installed in the "ClamWin" folder, which contains a lib and bin folder, however just using "Path".parent returns me the bin folder, I will to go all the way up to the ClamWin folder and ensure that it will work for the other applications eg Minecraft.exe in Minecraft folder avp.exe in the kaspersky folder例如,ClamWin.exe 安装在“ClamWin”文件夹中,该文件夹包含一个 lib 和 bin 文件夹,但是仅使用“Path”.parent 将返回 bin 文件夹,我将一直到 ClamWin 文件夹和确保它适用于其他应用程序,例如卡巴斯基文件夹中 Minecraft 文件夹中的 Minecraft.exe

Using python使用蟒蛇

If it is only used on windows, I think you can consider using the registry to obtain the path: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Bandizip.exe如果只在windows上使用,我觉得可以考虑使用注册表获取路径: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Bandizip.exe

If you get the parent folder recursively until you reach 'Program Files', this may not be universal如果您递归获取父文件夹,直到到达“程序文件”,这可能不是通用的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM