Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-25
3
Medium Priority
?
1,511 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 29

Accepted Solution

by:
pepr earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

916 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