Python _winreg.DeleteKey() Examples

The following are 22 code examples of _winreg.DeleteKey(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _winreg , or try the search function .
Example #1
Source File: iebutton.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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
# 
Example #2
Source File: winreg.py    From uac-a-mola with GNU General Public License v3.0 5 votes vote down vote up
def restore(self, key, value=''):
        """ Restore to the last registry known state
        """
        if self.no_restore is False:
            new_sk = self.last_created['new_sk']
            k = self.last_created['key']
            exist_sk = self.last_created['existing_sk']

            self.del_value(key, value)

            if new_sk is not None:
                for i in range(len(new_sk)):
                    if i == 0:
                        try:
                            winreg.DeleteKey(k, "\\".join(exist_sk + new_sk))
                        except WindowsError as error:
                            pass
                    else:
                        try:
                            winreg.DeleteKey(k, "\\".join(
                                exist_sk + new_sk[:-i]))
                        except WindowsError as error:
                            pass

                self.last_created['new_sk'] = None
                self.last_created['existing_sk'] = None
                self.last_created['key'] = None 
Example #3
Source File: shell_view.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolderRoot._reg_clsid_)
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #4
Source File: folder_view.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    paths = [
        "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace\\" + ShellFolder._reg_clsid_,
        "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_),
    ]
    for path in paths:
        try:
            _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, path)
        except WindowsError, details:
            import errno
            if details.errno != errno.ENOENT:
                print "FAILED to remove %s: %s" % (path, details) 
Example #5
Source File: context_menu.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
                                "Python.File\\shellex\\ContextMenuHandlers\\PythonSample")
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #6
Source File: empty_volume_cache.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \
         % (EmptyVolumeCache._reg_desc_,)
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, kn)
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #7
Source File: column_provider.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
                            "Folder\\ShellEx\\ColumnHandlers\\" + \
                            str(ColumnProvider._reg_clsid_) )
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #8
Source File: copy_hook.py    From Email_My_PC with MIT License 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
                                "directory\\shellex\\CopyHookHandlers\\" +
                            ShellExtension._reg_desc_)
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #9
Source File: Install.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Uninstall():
    AddOrRemoveHIDKeys(False)
    key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, ServiceKey, 0, reg.KEY_ALL_ACCESS)
    reg.DeleteKey(key, "AlternateMceIrService")
    service = Service(u"AlternateMceIrService")
    service.Stop()
    service.Uninstall()
    print "Service successfully uninstalled" 
Example #10
Source File: ext_server_uacamola.py    From uac-a-mola with GNU General Public License v3.0 5 votes vote down vote up
def delete_key(self, key, subkey):
        """ Deletes a particular key
        """
        try:
            return winreg.DeleteKey(key, subkey)
        except WindowsError as error:
            return None 
Example #11
Source File: ext_server_uacamola.py    From uac-a-mola with GNU General Public License v3.0 5 votes vote down vote up
def restore(self, key, value=''):
        """ Restore to the last registry known state
        """
        if self.no_restore is False:
            new_sk = self.last_created['new_sk']
            k = self.last_created['key']
            exist_sk = self.last_created['existing_sk']

            self.del_value(key, value)

            if new_sk is not None:
                for i in range(len(new_sk)):
                    if i == 0:
                        try:
                            winreg.DeleteKey(k, "\\".join(exist_sk + new_sk))
                        except WindowsError as error:
                            return None
                    else:
                        try:
                            winreg.DeleteKey(k, "\\".join(
                                exist_sk + new_sk[:-i]))
                        except WindowsError as error:
                            return None

                self.last_created['new_sk'] = None
                self.last_created['existing_sk'] = None
                self.last_created['key'] = None
        return True 
Example #12
Source File: winreg.py    From uac-a-mola with GNU General Public License v3.0 5 votes vote down vote up
def delete_key(self, key, subkey):
        """ Deletes a particular key
        """
        try:
            return winreg.DeleteKey(key, subkey)
        except WindowsError as error:
            print "Error al eliminar la clave" 
Example #13
Source File: regobj.py    From NVDARemote with GNU General Public License v2.0 5 votes vote down vote up
def del_subkey(self,name):
        """Delete the named subkey, and any values or keys it contains."""
        self.sam |= KEY_WRITE
        subkey = self.get_subkey(name)
        subkey.clear()
        _winreg.DeleteKey(subkey.parent.hkey,subkey.name) 
Example #14
Source File: recipe-577381.py    From code with MIT License 5 votes vote down vote up
def __delitem__(self, k):
        key, subkey = self._compute_subkey(k)
        with _winreg.OpenKey(self._hive, key,
                             0, _winreg.KEY_ALL_ACCESS) as root_key:
            try:
                _winreg.DeleteValue(root_key, subkey)
            except WindowsError:
                try:
                    _winreg.DeleteKey(root_key, subkey)
                except WindowsError:
                    raise KeyError 
Example #15
Source File: outlookAddin.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def UnregisterAddin(klass):
    import _winreg
    try:
        _winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins\\" + klass._reg_progid_)
    except WindowsError:
        pass 
Example #16
Source File: excelAddin.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def UnregisterAddin(klass):
    import _winreg
    try:
        _winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins\\" + klass._reg_progid_)
    except WindowsError:
        pass 
Example #17
Source File: shell_view.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolderRoot._reg_clsid_)
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #18
Source File: folder_view.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    paths = [
        "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace\\" + ShellFolder._reg_clsid_,
        "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_),
    ]
    for path in paths:
        try:
            _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, path)
        except WindowsError, details:
            import errno
            if details.errno != errno.ENOENT:
                print "FAILED to remove %s: %s" % (path, details) 
Example #19
Source File: context_menu.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
                                "Python.File\\shellex\\ContextMenuHandlers\\PythonSample")
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #20
Source File: empty_volume_cache.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \
         % (EmptyVolumeCache._reg_desc_,)
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, kn)
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #21
Source File: column_provider.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
                            "Folder\\ShellEx\\ColumnHandlers\\" + \
                            str(ColumnProvider._reg_clsid_) )
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise 
Example #22
Source File: copy_hook.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def DllUnregisterServer():
    import _winreg
    try:
        key = _winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT,
                                "directory\\shellex\\CopyHookHandlers\\" +
                            ShellExtension._reg_desc_)
    except WindowsError, details:
        import errno
        if details.errno != errno.ENOENT:
            raise