Python _winreg 模块,DeleteValue() 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用_winreg.DeleteValue()

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def unregister(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.DeleteValue( hKey, "ButtonText" )
        _winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        _winreg.DeleteValue( hKey, "CLSID" )
        _winreg.DeleteValue( hKey, "Default Visible" )
        _winreg.DeleteValue( hKey, "ToolTip" )
        _winreg.DeleteValue( hKey, "Icon" )
        _winreg.DeleteValue( hKey, "HotIcon" )
        _winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print "Couldn't delete Standard toolbar regkey."
    else:
        print "Deleted Standard toolbar regkey."

#
# test implementation
#
项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete 
    os.remove(sys.argv[0])
    sys.exit(0)
项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    os.remove(sys.argv[0])
    sys.exit(0)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def unregister(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.DeleteValue( hKey, "ButtonText" )
        _winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        _winreg.DeleteValue( hKey, "CLSID" )
        _winreg.DeleteValue( hKey, "Default Visible" )
        _winreg.DeleteValue( hKey, "ToolTip" )
        _winreg.DeleteValue( hKey, "Icon" )
        _winreg.DeleteValue( hKey, "HotIcon" )
        _winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print "Couldn't delete Standard toolbar regkey."
    else:
        print "Deleted Standard toolbar regkey."

#
# test implementation
#
项目:MrRAT    作者:user696    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete basicRAT
    os.remove(sys.argv[0])
    sys.exit(0)
项目:bloodyshell    作者:deadPix3l    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete basicRAT
    os.remove(sys.argv[0])
    sys.exit(0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def unregister(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.DeleteValue( hKey, "ButtonText" )
        _winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        _winreg.DeleteValue( hKey, "CLSID" )
        _winreg.DeleteValue( hKey, "Default Visible" )
        _winreg.DeleteValue( hKey, "ToolTip" )
        _winreg.DeleteValue( hKey, "Icon" )
        _winreg.DeleteValue( hKey, "HotIcon" )
        _winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print "Couldn't delete Standard toolbar regkey."
    else:
        print "Deleted Standard toolbar regkey."

#
# test implementation
#
项目:basicRAT    作者:vesche    | 项目源码 | 文件源码
def selfdestruct(plat):
    if plat == 'win':
        import _winreg
        from _winreg import HKEY_CURRENT_USER as HKCU

        run_key = r'Software\Microsoft\Windows\CurrentVersion\Run'

        try:
            reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_ALL_ACCESS)
            _winreg.DeleteValue(reg_key, 'br')
            _winreg.CloseKey(reg_key)
        except WindowsError:
            pass

    elif plat == 'nix':
        pass

    elif plat == 'mac':
        pass

    # self delete basicRAT
    os.remove(sys.argv[0])
    sys.exit(0)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __del_values(self):
        'Private class method.'
        try:
            while True:
                _winreg.DeleteValue(self.__self, _winreg.EnumValue(self.__self, 0)[0])
        except EnvironmentError:
            pass
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __del_value(self):
        'Private class method.'
        _winreg.DeleteValue(self.__self, '')
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __delitem__(self, key):
        'Delete the specified value.'
        _winreg.DeleteValue(self.__self, key)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __del_values(self):
        'Private class method.'
        try:
            while True:
                _winreg.DeleteValue(self.__key, _winreg.EnumValue(self.__key, 0)[0])
        except EnvironmentError:
            pass
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __del_value(self):
        'Private class method.'
        _winreg.DeleteValue(self.__key, '')
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __del_values(self):
        'Private class method.'
        try:
            while True:
                _winreg.DeleteValue(self.__key, _winreg.EnumValue(self.__key, 0)[0])
        except EnvironmentError:
            pass
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __del_value(self):
        'Private class method.'
        _winreg.DeleteValue(self.__key, '')
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __delitem__(self, key):
        'Delete the specified value.'
        _winreg.DeleteValue(self.__key, key)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def DllUnregisterServer():
    comclass = IEToolbar

    # unregister toolbar from internet explorer
    try:
        print "Trying to unregister Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        _winreg.DeleteValue( hkey, comclass._reg_clsid_ )
    except WindowsError:
        print "Couldn't delete registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Deleting reg key succeeded.\n"

# entry point
项目:uac-a-mola    作者:ElevenPaths    | 项目源码 | 文件源码
def del_value(self, key, value=''):
        if self.no_restore is False:
            try:
                return winreg.DeleteValue(key, value)
            except WindowsError as error:
                print "Error al eliminar el valor"
项目:Intranet-Penetration    作者:yuxiaokui    | 项目源码 | 文件源码
def remove(name):
        if not exists(name):
            return

        """delete an autostart entry"""
        key = get_runonce()
        _winreg.DeleteValue(key, name)
        _winreg.CloseKey(key)
项目:MKFQ    作者:maojingios    | 项目源码 | 文件源码
def remove(name):
        if not exists(name):
            return

        """delete an autostart entry"""
        key = get_runonce()
        _winreg.DeleteValue(key, name)
        _winreg.CloseKey(key)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def DllUnregisterServer():
    comclass = IEToolbar

    # unregister toolbar from internet explorer
    try:
        print "Trying to unregister Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        _winreg.DeleteValue( hkey, comclass._reg_clsid_ )
    except WindowsError:
        print "Couldn't delete registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Deleting reg key succeeded.\n"

# entry point
项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def __remove_from_startup_programs(self):
      '''
      @summary: Removes Crypter from the list of startup programs
      @todo: Code and test
      '''

      try:
          reg = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, self.STARTUP_REGISTRY_LOCATION, 0, _winreg.KEY_SET_VALUE)
          _winreg.DeleteValue(reg, "Crypter")
          _winreg.CloseKey(reg)
      except WindowsError:
          pass
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def DllUnregisterServer():
    comclass = IEToolbar

    # unregister toolbar from internet explorer
    try:
        print "Trying to unregister Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        _winreg.DeleteValue( hkey, comclass._reg_clsid_ )
    except WindowsError:
        print "Couldn't delete registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Deleting reg key succeeded.\n"

# entry point
项目:xxNet    作者:drzorm    | 项目源码 | 文件源码
def remove(name):
        if not exists(name):
            return

        """delete an autostart entry"""
        key = get_runonce()
        _winreg.DeleteValue(key, name)
        _winreg.CloseKey(key)
项目:keypirinha-plugins    作者:EhsanKia    | 项目源码 | 文件源码
def __delitem__(self,name):
        """Item deletion deletes key values."""
        self.sam |= KEY_SET_VALUE
        try:
            _winreg.DeleteValue(self.hkey,name)
        except WindowsError:
            raise KeyError("no such value: '%s'" % (name,))
项目:maestro    作者:InWorldz    | 项目源码 | 文件源码
def __delitem__(self, key):
        # Delete a string value or a subkey, depending on the type
        try:
            item = self[key]
        except:
            return  # Silently ignore bad keys
        itemtype = type(item)
        if itemtype is str:
            _winreg.DeleteValue(self.keyhandle, key)
        elif isinstance(item, RegistryDict):
            # Delete everything in the subkey, then the subkey itself
            item.clear()
            _winreg.DeleteKey(self.keyhandle, key)
        else:
            raise ValueError, "Unknown item type in RegistryDict"
项目:EasierLife    作者:littlecodersh    | 项目源码 | 文件源码
def set_proxy(keyList):
    if keyList.has_key('AutoConfigURL'): _winreg.DeleteValue(key, 'AutoConfigURL')
    if keyList['ProxyEnable'] != 1: _winreg.SetValueEx(key, 'ProxyEnable', 0, _winreg.REG_DWORD, 1)
    if not keyList.has_key('ProxyServer'): 
        _winreg.CreateKey(key, 'ProxyServer')
        _winreg.SetValueEx(key, 'ProxyServer', 0, _winreg.REG_SZ, PROXY_PORT)
    elif keyList['ProxyServer'] != PROXY_PORT: 
        _winreg.SetValueEx(key, 'ProxyServer', 0, _winreg.REG_SZ, PROXY_PORT)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def remmoveEnvironment(scope, name):
    assert scope in ('user', 'system')

    if platform.system() == 'Windows':
        root, subkey = getWindowsEnvironmentKey(scope)
        key = winreg.OpenKey(root, subkey, 0, winreg.KEY_ALL_ACCESS)

        try:
            winreg.DeleteValue(key, name)
        except WindowsError:
            pass
    else:
        removeLinuxEnvironment(scope, name)
项目:django-learning    作者:adoggie    | 项目源码 | 文件源码
def setAutoRunWithOsStart(key,app,start=True):
    import _winreg
    try:
        r = _winreg.OpenKey(
                 _winreg.HKEY_LOCAL_MACHINE,
                r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0,_winreg.KEY_WRITE)
        if start:
            _winreg.SetValueEx(r,key,0,_winreg.REG_SZ,app)
        else:
            _winreg.DeleteValue(r,key)
    except:
        traceback.print_exc()
项目:django-learning    作者:adoggie    | 项目源码 | 文件源码
def setAutoRunWithOsStart(key,app,start=True):
    import _winreg
    try:
        r = _winreg.OpenKey(
                 _winreg.HKEY_LOCAL_MACHINE,
                r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0,_winreg.KEY_WRITE)
        if start:
            _winreg.SetValueEx(r,key,0,_winreg.REG_SZ,app)
        else:
            _winreg.DeleteValue(r,key)
    except:
        traceback.print_exc()
项目:Docker-XX-Net    作者:kuanghy    | 项目源码 | 文件源码
def remove(name):
        if not exists(name):
            return

        """delete an autostart entry"""
        key = get_runonce()
        _winreg.DeleteValue(key, name)
        _winreg.CloseKey(key)
项目:keyrings.alt    作者:jaraco    | 项目源码 | 文件源码
def delete_password(self, service, username):
        """Delete the password for the username of the service.
        """
        try:
            key_name = r'Software\%s\Keyring' % service
            hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_name, 0,
                winreg.KEY_ALL_ACCESS)
            winreg.DeleteValue(hkey, username)
            winreg.CloseKey(hkey)
        except WindowsError:
            e = sys.exc_info()[1]
            raise PasswordDeleteError(e)
        self._delete_key_if_empty(service)