Python winreg.DeleteKey() Examples
The following are 7
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: Windows.py From keyrings.alt with MIT License | 6 votes |
def _delete_key_if_empty(self, service): key_name = self._key_for_service(service) key = winreg.OpenKey( winreg.HKEY_CURRENT_USER, key_name, 0, winreg.KEY_ALL_ACCESS ) try: winreg.EnumValue(key, 0) return except WindowsError: pass winreg.CloseKey(key) # it's empty; delete everything while key_name != 'Software': parent, sep, base = key_name.rpartition('\\') key = winreg.OpenKey( winreg.HKEY_CURRENT_USER, parent, 0, winreg.KEY_ALL_ACCESS ) winreg.DeleteKey(key, base) winreg.CloseKey(key) key_name = parent
Example #2
Source File: postinstall_simnibs.py From simnibs with GNU General Public License v3.0 | 5 votes |
def uninstaller_cleanup(): if sys.platform == 'win32': try: with winreg.OpenKey( winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', access=winreg.KEY_WRITE) as reg: winreg.DeleteKey(reg, 'SimNIBS') except FileNotFoundError: pass
Example #3
Source File: regobj.py From NVDARemote with GNU General Public License v2.0 | 5 votes |
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 #4
Source File: registry.py From BoomER with GNU General Public License v3.0 | 5 votes |
def del_key(self): try: k = winreg.DeleteKey(self.key, self.subkey) to_return = self._return_success(k) self.current_key = None except WindowsError as e: to_return = self._return_error(str(e)) return to_return
Example #5
Source File: ext_server_uacamola.py From uac-a-mola with GNU General Public License v3.0 | 5 votes |
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 #6
Source File: ext_server_uacamola.py From uac-a-mola with GNU General Public License v3.0 | 5 votes |
def delete_key(self, key, subkey): """ Deletes a particular key """ try: return winreg.DeleteKey(key, subkey) except WindowsError as error: return None
Example #7
Source File: windows.py From start_jupyter_cm with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _remove_jupyter_here(all_users): if all_users: h_key_base = winreg.HKEY_LOCAL_MACHINE install_type = "all users" else: h_key_base = winreg.HKEY_CURRENT_USER install_type = "single user" for terminal in ('qtconsole', 'notebook', 'lab'): try: winreg.DeleteKey( h_key_base, r'Software\Classes\Directory\shell\jupyter_%s_here%s\Command' % ( terminal, CONDA_ENV_LABEL.replace(" ", "_"))) winreg.DeleteKey( h_key_base, r'Software\Classes\Directory\shell\jupyter_%s_here%s' % ( terminal, CONDA_ENV_LABEL.replace(" ", "_"))) winreg.DeleteKey( h_key_base, r'Software\Classes\Directory\Background\shell\jupyter_%s_here%s\Command' % ( terminal, CONDA_ENV_LABEL.replace(" ", "_"))) winreg.DeleteKey( h_key_base, r'Software\Classes\Directory\Background\shell\jupyter_%s_here%s' % ( terminal, CONDA_ENV_LABEL.replace(" ", "_"))) print("Jupyter %s here%s context menu entry removed for %s." % ( terminal, CONDA_ENV_LABEL, install_type)) except FileNotFoundError: # If this fails it is because it was not installed, so nothing to # worry about. pass