Python Forum
How to ignore - ERROR: The system was unable to find the specified registry key or va
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to ignore - ERROR: The system was unable to find the specified registry key or va
#1
def isAlreadyInstalled(lookupRegistryKey):
    consoleLines = os.popen('reg query "' + APP_REGISTRY_KEY + "\\" + VERSION_SYSTEM_NAME + '"').readlines()
    if len(consoleLines) == 0:
        return False
    return True
I have this snippet. The problem is that it gives this error in the command line without stoping the execution ( wich is ok for my cas), I just want to ignore this error.

ERROR: The system was unable to find the specified registry key or value.
Reply
#2
Does it also error in python?
Reply
#3
No, my script is working ok. But this just pops there and i don't want to see it.

I'm looping for 5 minutes, call this method evrey second to check if a program is installed or not. I want to ignore this if possible somehow here inside the method
Reply
#4
use try/except block, with the except capturing the specific error
and content of except 'pass'
Reply
#5
  
 def isAlreadyInstalled(lookupRegistryKey):
        try:
            consoleLines = os.popen('reg query "' + APP_REGISTRY_KEY + "\\" + VERSION_SYSTEM_NAME + '"').readlines()
            if len(consoleLines) == 0:
                return False
            return True
        except OSError:
            pass
This is not working.
Reply
#6
you haven't shown the error message.
Post that verbatim please
Reply
#7
This is the error shown in the command line:

ERROR: The system was unable to find the specified registry key or value.
Reply
#8
This error does not look like a python generated error traceback as it is incomplete.
if that's all you have, then you need to show more code, especially the 'lookupRegistryKey'
method or function (or package name if in a package). Soesn't loog like a winreg error either.

Can't help with information provided.
Reply
#9
If it's not stopping the execution of the program, it's not an error from Python's perspective. A try/except block certainly won't work. I don't know if there is anything you can do in Python to stop it. Is there perhaps an option to the system command you are using that would suppress the error output?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#10
APP_REGISTRY_KEY - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
lookupRegistryKey = theNameOfTheApplication

@ichabod801 - there is but in this case my condition( if len(consoleLines) == 0: ) will always be false since.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to add Python folder in Windows Registry ? Touktouk 1 206 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 1,490 Jul-31-2023, 11:42 AM
Last Post: deanhystad
  Read complete windows registry? fredep57 3 901 Mar-15-2023, 08:14 PM
Last Post: buran
  Error when using FIND WJSwan 2 855 Jan-27-2023, 05:49 AM
Last Post: deanhystad
  Ignore WakeWord after it's said Extra 2 1,136 Apr-01-2022, 12:32 AM
Last Post: Extra
  How to ignore "Retrying (Retry(total=2, connect=2, read=5, redirect=5, status=None))" const 3 2,635 Mar-26-2022, 08:55 AM
Last Post: ndc85430
  Error in find pearson correlation function erneelgupta 1 1,809 Mar-01-2022, 03:41 PM
Last Post: stevendaprano
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,163 Aug-17-2021, 05:24 PM
Last Post: Franky77
Exclamation "System cannot find path specified"(Geany) kiwi99 2 3,768 Mar-18-2021, 07:37 PM
Last Post: kiwi99
  How to add new registry key shlomi27 3 10,199 Feb-04-2021, 05:45 PM
Last Post: reidnax

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020