Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-25
3
Medium Priority
?
1,435 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
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…

722 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