mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-29 17:27:13 +08:00
Fix: Uninstall registry not closed
This commit is contained in:
@@ -50,9 +50,10 @@ class VirtualBoxEmulator:
|
|||||||
return root
|
return root
|
||||||
|
|
||||||
try:
|
try:
|
||||||
reg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG}\\{self.name}', 0)
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG}\\{self.name}', 0) as reg:
|
||||||
|
res = winreg.QueryValueEx(reg, 'UninstallString')[0]
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
reg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG_2}\\{self.name}', 0)
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, f'{self.UNINSTALL_REG_2}\\{self.name}', 0) as reg:
|
||||||
res = winreg.QueryValueEx(reg, 'UninstallString')[0]
|
res = winreg.QueryValueEx(reg, 'UninstallString')[0]
|
||||||
|
|
||||||
file = re.search('"(.*?)"', res)
|
file = re.search('"(.*?)"', res)
|
||||||
@@ -70,14 +71,14 @@ class VirtualBoxEmulator:
|
|||||||
str: Installation dir or None
|
str: Installation dir or None
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
reg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path, 0)
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path, 0) as reg:
|
||||||
root = winreg.QueryValueEx(reg, key)[0]
|
root = winreg.QueryValueEx(reg, key)[0]
|
||||||
if os.path.exists(root):
|
if os.path.exists(root):
|
||||||
return root
|
return root
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
reg = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0)
|
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0) as reg:
|
||||||
root = winreg.QueryValueEx(reg, key)[0]
|
root = winreg.QueryValueEx(reg, key)[0]
|
||||||
if os.path.exists(root):
|
if os.path.exists(root):
|
||||||
return root
|
return root
|
||||||
|
|||||||
Reference in New Issue
Block a user