Hey, Im new to python and trying to code a script which should enable/disable usb using winreg. Whats wrong in this code
code:
import winreg
def usbenordis(value):
try:
keyval=r"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlS et\Services\UsbStor"
if not os.path.exists("keyval"):
key = CreateKey(HKEY_CURRENT_USER,keyval)
Registrykey= OpenKey(HKEY_CURRENT_USER, r"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Serv ices\UsbStor", 0,KEY_WRITE)
if value == true:
SetValueEx(Registrykey,"start",0,REG_SZ,4)
print "usb disabled"
elif value == false:
SetValueEx(Registrykey,"start",0,REG_SZ,3)
print "usb enabled"
CloseKey(Registrykey)
return True
except WindowsError:
return False
def main():
x=usbenordis(true)