Python Forum
[WinReg]>Issue when reading a registry key
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WinReg]>Issue when reading a registry key
#1
Hello All,

I'm trying without success to read the key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet\IEXPLORE.EXE\DefaultIcon

here is the code I'm using :

from winreg import * from time import sleep n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_64KEY) t = (EnumValue(n,0)) print(t)
It fails with error:
Output:
FileNotFoundError": [WinError 2] The system cannot find the file specified
What am I doing wrong ?

Thanks for your help
Reply
#2
Try this:

try:     n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_64KEY) except FileNotFoundError:     n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_32KEY)
SO
https://msdn.microsoft.com/en-us/library...S.85).aspx
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
(Mar-28-2017, 06:53 AM)wavic Wrote: Try this:

try:     n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_64KEY) except FileNotFoundError:     n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_32KEY)
SO
https://msdn.microsoft.com/en-us/library...S.85).aspx

Hi Wavic !

I tried but got same error... however, I can see by using regedit that the key is visible from 32-bit registry view and 64-bit registry view as well...
Reply
#4
Look better in Regedit.
Under "StartMenuInternet" i have browsers not "DefaultIcon".
Test:
from winreg import * key = OpenKey(HKEY_LOCAL_MACHINE,  r'SOFTWARE\Clients\StartMenuInternet\Google Chrome\Capabilities') # Two way to read name = QueryValueEx(key, "ApplicationName") t = (EnumValue(key, 2))
Use:
>>> name ('Google Chrome', 1) >>> t ('ApplicationName', 'Google Chrome', 1) >>> name[0] 'Google Chrome' >>> t[1] 'Google Chrome'
Reply
#5
(Mar-28-2017, 11:44 AM)snippsat Wrote: Look better in Regedit.
Under "StartMenuInternet" i have browsers not "DefaultIcon".

Yes ! you're right ! Thank you for pointing out my mistake and saved my day :-)

(Mar-28-2017, 08:02 AM)CSA75 Wrote:
(Mar-28-2017, 06:53 AM)wavic Wrote: Try this:

try:     n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_64KEY) except FileNotFoundError:     n = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\Clients\StartMenuInternet\DefaultIcon', 0, KEY_READ | KEY_WOW64_32KEY)
SO
https://msdn.microsoft.com/en-us/library...S.85).aspx

Hi Wavic !

I tried but got same error... however, I can see by using regedit that the key is visible from 32-bit registry view and  64-bit registry view as well...
Actually you were right ! I was trying with an incorrect registry key path..
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to add Python folder in Windows Registry ? Touktouk 1 1,837 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Read complete windows registry? fredep57 3 2,498 Mar-15-2023, 08:14 PM
Last Post: buran
  I have an issue with Netmiko Error reading SSH protocol banner omarhegazy 2 6,392 May-16-2022, 06:05 PM
Last Post: omarhegazy
  How to add new registry key shlomi27 3 13,256 Feb-04-2021, 05:45 PM
Last Post: reidnax
  Issue with HX711 reading duckredbeard 0 3,246 Aug-28-2020, 10:00 AM
Last Post: duckredbeard
  Automatic registering python to registry kozaizsvemira 1 3,758 Oct-22-2019, 11:23 AM
Last Post: kozaizsvemira
  Python 2.7.13 Issue Reading .txt files Properly username1145 3 3,772 Mar-24-2019, 03:08 PM
Last Post: username1145
  How to ignore - ERROR: The system was unable to find the specified registry key or va asheru93 9 10,087 Feb-04-2019, 06:35 AM
Last Post: asheru93
  Issue with reading CSV file nnsatpute 12 8,820 Dec-19-2018, 12:08 PM
Last Post: Gribouillis
  Issue in reading a text file contains dict data bharathappriyan 4 4,822 Sep-27-2018, 01:45 PM
Last Post: Larz60+

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.