-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfull_tray.pyw
39 lines (33 loc) · 1.17 KB
/
full_tray.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import itertools
import winreg
def main():
access1 = winreg.KEY_READ
access2 = winreg.KEY_SET_VALUE | winreg.KEY_QUERY_VALUE
key_path = r"Control Panel\NotifyIconSettings"
super_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, access=access1)
for index in itertools.count():
try:
name = winreg.EnumKey(super_key, index)
except OSError:
break # no more keys
subkey = winreg.OpenKey(super_key, name, access=access2)
examine(name, subkey)
winreg.CloseKey(subkey)
winreg.CloseKey(super_key)
# noinspection PyUnboundLocalVariable
print(f"Done for {index} keys")
def examine(name, subkey):
try:
value, type_ = winreg.QueryValueEx(subkey, "IsPromoted")
if value == 1 and type_ == winreg.REG_DWORD:
return # already correct
except FileNotFoundError:
pass # new
winreg.SetValueEx(subkey, "IsPromoted", 0, winreg.REG_DWORD, 1)
try:
value, _ = winreg.QueryValueEx(subkey, "ExecutablePath")
except FileNotFoundError:
value = "unknown path"
print(f"Set IsPromoted=1 for {name} ({value})")
if __name__ == "__main__":
main()