It seems to work but the output isn't right. I do have 10 things in the Run
folder but the out put is not telling me what they are, it just says none
for each entry. I guess that I am not sure what to do now. I can do this
in Perl and other languages but I really want to learn Python.
Here is what I have done:
import _winreg
host = "127.0.0.1" # local host
key = _winreg.ConnectRegistry(host, _winreg.HKEY_LOCAL_MACHINE)
hkey = _winreg.OpenKey(key,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
i = 0
regKeys = []
try:
while 1:
test_key = regKeys.append(_winreg.EnumValue(hkey, i))
print test_key
i += 1
except EnvironmentError:
pass
when I run this script I am getting this for my output:
None
None
None
None
None
None
None
None
None
None
Thanks
Tim
Timothy F. Gallagher
Timothyg- AT 0-Motorola.com
�
________________________________________
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 13, 2005 9:45 PM
To: Gallagher Timothy-TIMOTHYG; [email protected]
Subject: Re: [Tutor] _winreg problems enumerating
Hi Tim,
Hmmm, I may have to play with _winreg, is is new with Python 2.4?
Anyway, from the _winreg docs -
EnumValue(
key, index)
Enumerates values of an open registry key, returning a tuple.
key is an already open key, or any one of the predefined HKEY_* constants.
index is an integer that identifies the index of the value to retrieve.
The function retrieves the name of one subkey each time it is called. It is
typically called repeatedly, until an EnvironmentError exception is raised,
indicating no more values.
There's your issue -
E_key =
_winreg.EnumValue(key,r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
The second value needs to be an integer that is an index.
Typical usage would look like this -
i = 0
regKeys = []
try:
� while 1:
����� regKeys.append(_winreg.EnumValue(key, i))
������ i += 1
except EnvironmentError:
���� pass
Good luck,
Liam Clarke
On 4/14/05, Gallagher Timothy-TIMOTHYG <[EMAIL PROTECTED]> wrote:
am new to python and want to learn this language.��I am having troubles
finding examples and tutorials for use on windows boxes.��I do most of my
stuff in perl and php but want better socket support, so I am giving python
a try.��I am writing a script to connect to remote registry's because of
this new IM virus.��I can create reg entries and delete them but I cannot
enumerate them, here is my code.
import _winreg
host = " 127.0.0.1" # local host
key = _winreg.ConnectRegistry(host, _winreg.HKEY_LOCAL_MACHINE)
E_key = _winreg.EnumValue(key,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
I get an error when I run the script:
Traceback (most recent call last):
��File "reg4.py", line 9, in ?
����E_key = _winreg.EnumValue(key,
r"SOFTWARE\Microsoft\Windows\CurrentVersion\R
un")
TypeError: an integer is required
Can someone tell me what I am doing wrong???
Thanks
Timothy F. Gallagher
Timothyg- at -Motorola.com
_______________________________________________
Tutor [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor
--
'There is only one basic human right, and that is to do as you damn well
please.
And with it comes the only basic human duty, to take the consequences.'
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor