B
Bart Nessux
for i in range(10000):
try:
n,v,t = EnumValue(open_key,i)
# n == name of the registry object.
# v == object's value.
# t == object's type.
print n,v,t
except EnvironmentError:
print "\nThere are", i, "registy objects under this key."
break
Is there a way to reference an item within a tuple that you've iterated
over? The above code upacks a tuple into 3 variables n,v and t. In order
to do this, it loops over a Windows registry key. Let's say that I want
to find out which n == 'EnableFirewall' and then read the value of its
v... how can I do that?
BTY, the below code turns off the 'Windows Firewall' on Windows XP
Service Pack 2... I wrote it as a test after reading that MS is allowing
3rd party programs to programmatically enable or disable the firewall
through the registry.
from _winreg import *
sub_key =
r"SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile"
open_key = OpenKey(HKEY_LOCAL_MACHINE, sub_key, 0, KEY_ALL_ACCESS)
SetValueEx(open_key,'EnableFirewall',0,REG_DWORD,0)
CloseKey(open_key)
try:
n,v,t = EnumValue(open_key,i)
# n == name of the registry object.
# v == object's value.
# t == object's type.
print n,v,t
except EnvironmentError:
print "\nThere are", i, "registy objects under this key."
break
Is there a way to reference an item within a tuple that you've iterated
over? The above code upacks a tuple into 3 variables n,v and t. In order
to do this, it loops over a Windows registry key. Let's say that I want
to find out which n == 'EnableFirewall' and then read the value of its
v... how can I do that?
BTY, the below code turns off the 'Windows Firewall' on Windows XP
Service Pack 2... I wrote it as a test after reading that MS is allowing
3rd party programs to programmatically enable or disable the firewall
through the registry.
from _winreg import *
sub_key =
r"SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile"
open_key = OpenKey(HKEY_LOCAL_MACHINE, sub_key, 0, KEY_ALL_ACCESS)
SetValueEx(open_key,'EnableFirewall',0,REG_DWORD,0)
CloseKey(open_key)