Solved

WindowsError: [Error 2] The system cannot find the file specified

Posted on 2011-03-25
3
1,174 Views
Last Modified: 2012-05-11
I keep getting this error
 Traceback (most recent call last):
File "C:/Documents and Settings/dolamite/Desktop/reg.py", line 4, in <module>
    aKey = OpenKey(aReg, r'SOFTWARE\SEMS_Event_Managment')
WindowsError: [Error 2] The system cannot find the file specified


from _winreg import *

aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r'SOFTWARE\SEMS_Event_Managment')
expiration = QueryValueEx(aKey, "Expiration")
print expiration
CloseKey(aKey)

Open in new window


I am trying to get the expiration date from the registry

the exact location of the registry Im trying to locate is
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\SEMS_Event_Managment

Expiration

what am I doing wrong ?

 
0
Comment
Question by:dolamitejenkins
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
pepr earned 500 total points
ID: 35218472
You can simplify it the following way:

from _winreg import *

aKey = OpenKey(HKEY_LOCAL_MACHINE, r'SOFTWARE\SEMS_Event_Managment')
expiration = QueryValueEx(aKey, "Expiration")
print expiration
CloseKey(aKey)

Open in new window


However, such error message can be observed when there is no such key in registry.  Check it with regedit.exe.
0
 

Author Comment

by:dolamitejenkins
ID: 35218685
thank I will try this...
0
 

Author Closing Comment

by:dolamitejenkins
ID: 35220985
perfect thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now