Python _winreg.DeleteValue() Examples
The following are 23
code examples of _winreg.DeleteValue().
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 |
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: clean_registry_storage.py From AltFS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def cleanup(base_key_full_path): """Performs the clean up of AltFS applicable values from the Registry""" hive, base_key_path = split_key_path_to_hive_and_path(base_key_full_path) with _winreg.OpenKey( HIVES[hive], base_key_path, _winreg.KEY_SET_VALUE) as base_key: buckets_names = get_sub_keys(base_key) for bucket_name in buckets_names: print "iterating key: %s" % bucket_name values_to_delete = [] with get_bucket_key( HIVES[hive], "%s\\%s" % (base_key_path, bucket_name)) as key: for value_name in get_sub_values(key): print "iterating value name: %s" % value_name if is_value_name_applicable(buckets_names, value_name): values_to_delete.append(value_name) with get_bucket_key( HIVES[hive], "%s\\%s" % (base_key_path, bucket_name), desired_access=_winreg.KEY_SET_VALUE) as key: for value_name in values_to_delete: print "-- going to delete: %s" % value_name _winreg.DeleteValue(key, value_name)
Example #3
Source File: platform.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def enforce_shortcut(config, log_func): if os.name != 'nt': return path = win32api.GetModuleFileName(0) if 'python' in path.lower(): # oops, running the .py too lazy to make that work path = r"C:\Program Files\BitTorrent\bittorrent.exe" root_key = _winreg.HKEY_CURRENT_USER subkey = r'Software\Microsoft\Windows\CurrentVersion\run' key = _winreg.CreateKey(root_key, subkey) if config['launch_on_startup']: _winreg.SetValueEx(key, app_name, 0, _winreg.REG_SZ, '"%s" --force_start_minimized' % path) else: try: _winreg.DeleteValue(key, app_name) except WindowsError, e: # value doesn't exist pass
Example #4
Source File: winreg.py From uac-a-mola with GNU General Public License v3.0 | 5 votes |
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"
Example #5
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def SetHidState(self, disableHid): """ Sets the HID registry values. Will raise WindowsError if not successful. """ key = reg.OpenKey( reg.HKEY_LOCAL_MACHINE, HID_SUB_KEY, 0, reg.KEY_ALL_ACCESS ) for i in xrange(4): valueName = 'CodeSetNum%i' % i if disableHid: reg.DeleteValue(key, valueName) else: reg.SetValueEx(key, valueName, 0, reg.REG_DWORD, i + 1)
Example #6
Source File: Install.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def AddOrRemoveHIDKeys(isInstall): HID_SUB_KEY = "SYSTEM\\CurrentControlSet\\Services\\HidIr\\Remotes\\745a17a0-74d3-11d0-b6fe-00a0c90f57d" ValuesToCheck = ['a','b'] for a in ValuesToCheck: tmpkey = HID_SUB_KEY+a try: key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, tmpkey, 0, reg.KEY_ALL_ACCESS) for i in xrange(4): valueName = 'CodeSetNum%i' % i if isInstall: reg.DeleteValue(key, valueName) else: reg.SetValueEx(key, valueName, 0, reg.REG_DWORD, i + 1) except WindowsError: continue
Example #7
Source File: RegistryStorageProvider.py From AltFS with BSD 3-Clause "New" or "Revised" License | 5 votes |
def delete_block(self, bucket_id, value_id): """Described in parent class""" with self._get_bucket_key(bucket_id, _winreg.KEY_SET_VALUE) as key: _winreg.DeleteValue(key, self._get_value_name( bucket_id, value_id))
Example #8
Source File: platform.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def write_language_file(lang): """Writes the language file. The language file contains the name of the selected language, not any translations.""" if lang != '': # system default get_language(lang) if os.name == 'nt': regko = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\BitTorrent") if lang == '': _winreg.DeleteValue(regko, "Language") else: lcid = None # I want two-way dicts for id, code in language.locale_sucks.iteritems(): if code.lower() == lang.lower(): lcid = id break if not lcid: raise KeyError(lang) _winreg.SetValueEx(regko, "Language", 0, _winreg.REG_SZ, str(lcid)) else: lang_file_name = language_path() lang_file = open(lang_file_name, 'w') lang_file.write(lang) lang_file.close()
Example #9
Source File: autorun.py From TinkererShell with GNU General Public License v3.0 | 5 votes |
def remove(name): """delete an autostart entry""" key = get_runonce() _winreg.DeleteValue(key, name) _winreg.CloseKey(key)
Example #10
Source File: persistence.py From byob with GNU General Public License v3.0 | 5 votes |
def _remove_registry_key(value=None, name='Java-Update-Manager'): try: if _methods['registry_key'].established: value = _methods['registry_key'].result try: key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 0, _winreg.KEY_ALL_ACCESS) _winreg.DeleteValue(key, name) _winreg.CloseKey(key) return (False, None) except: pass return (_methods['registry_key'].established, _methods['registry_key'].result) except Exception as e: util.log(str(e))
Example #11
Source File: persistence.py From byob with GNU General Public License v3.0 | 5 votes |
def _remove_registry_key(value=None, name='Java-Update-Manager'): try: if _methods['registry_key'].established: value = _methods['registry_key'].result try: key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 0, _winreg.KEY_ALL_ACCESS) _winreg.DeleteValue(key, name) _winreg.CloseKey(key) return (False, None) except: pass return (_methods['registry_key'].established, _methods['registry_key'].result) except Exception as e: util.log(str(e))
Example #12
Source File: ext_server_uacamola.py From uac-a-mola with GNU General Public License v3.0 | 5 votes |
def del_value(self, key, value=''): if self.no_restore is False: try: return winreg.DeleteValue(key, value) except WindowsError as error: return None
Example #13
Source File: regobj.py From NVDARemote with GNU General Public License v2.0 | 5 votes |
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,))
Example #14
Source File: recipe-577381.py From code with MIT License | 5 votes |
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: _registry.py From pipenv with MIT License | 5 votes |
def _set_all_values(self, rootkey, name, info, errors): with winreg.CreateKeyEx(rootkey, name, 0, winreg.KEY_WRITE | self._flags) as key: for k, v in info: if isinstance(v, PythonWrappedDict): self._set_all_values(key, k, v._items(), errors) elif isinstance(v, dict): self._set_all_values(key, k, v.items(), errors) elif v is None: winreg.DeleteValue(key, k) elif isinstance(v, str): winreg.SetValueEx(key, k, 0, winreg.REG_SZ, v) else: errors.append('cannot write {} to registry'.format(type(v)))
Example #16
Source File: _registry.py From pipenv with MIT License | 5 votes |
def set_value(self, value_name, value): with winreg.CreateKeyEx(self._root, self.subkey, 0, winreg.KEY_WRITE | self._flags) as key: if value is None: winreg.DeleteValue(key, value_name) elif isinstance(value, str): winreg.SetValueEx(key, value_name, 0, winreg.REG_SZ, value) else: raise TypeError('cannot write {} to registry'.format(type(value)))
Example #17
Source File: _registry.py From pythonfinder with MIT License | 5 votes |
def _set_all_values(self, rootkey, name, info, errors): with winreg.CreateKeyEx(rootkey, name, 0, winreg.KEY_WRITE | self._flags) as key: for k, v in info: if isinstance(v, PythonWrappedDict): self._set_all_values(key, k, v._items(), errors) elif isinstance(v, dict): self._set_all_values(key, k, v.items(), errors) elif v is None: winreg.DeleteValue(key, k) elif isinstance(v, str): winreg.SetValueEx(key, k, 0, winreg.REG_SZ, v) else: errors.append('cannot write {} to registry'.format(type(v)))
Example #18
Source File: _registry.py From pythonfinder with MIT License | 5 votes |
def set_value(self, value_name, value): with winreg.CreateKeyEx(self._root, self.subkey, 0, winreg.KEY_WRITE | self._flags) as key: if value is None: winreg.DeleteValue(key, value_name) elif isinstance(value, str): winreg.SetValueEx(key, value_name, 0, winreg.REG_SZ, value) else: raise TypeError('cannot write {} to registry'.format(type(value)))
Example #19
Source File: autorun.py From oss-ftp with MIT License | 5 votes |
def remove(name): if not exists(name): return """delete an autostart entry""" key = get_runonce() _winreg.DeleteValue(key, name) _winreg.CloseKey(key)
Example #20
Source File: px.py From px with MIT License | 5 votes |
def uninstall(): if check_installed() is True: runkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Run", 0, winreg.KEY_WRITE) winreg.DeleteValue(runkey, "Px") winreg.CloseKey(runkey) pprint("Px uninstalled successfully") else: pprint("Px is not installed") sys.exit() ### # Attach/detach console
Example #21
Source File: ietoolbar.py From ironpython2 with Apache License 2.0 | 5 votes |
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
Example #22
Source File: tools.py From syncthing-gtk with GNU General Public License v2.0 | 4 votes |
def set_run_on_startup(enabled, program_name, executable, icon="", description=""): """ Sets or unsets program to be ran on startup, either by XDG autostart or by windows registry. 'Description' parameter is ignored on Windows. Returns True on success. """ if is_ran_on_startup(program_name) == enabled: # Don't do anything if value is already set return if IS_WINDOWS: # Create/delete value for application in ...\Run key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, _winreg.KEY_ALL_ACCESS) if enabled: _winreg.SetValueEx(key, program_name, 0, _winreg.REG_SZ, '"%s"' % (executable,)) else: _winreg.DeleteValue(key, program_name) _winreg.CloseKey(key) else: # Create/delete application.desktop with provided values, # removing any hidding parameters desktopfile = os.path.join(get_config_dir(), "autostart", "%s.desktop" % (program_name,)) if enabled: try: os.makedirs(os.path.join(get_config_dir(), "autostart"), mode=0700) except Exception: # Already exists pass try: with open(desktopfile, "w") as f: desktop_contents = DESKTOP_FILE % (program_name, executable, icon, description) f.write(desktop_contents.encode('utf-8')) except Exception as e: # IO errors or out of disk space... Not really # expected, but may happen log.warning("Failed to create autostart entry: %s", e) return False else: try: if os.path.exists(desktopfile): os.unlink(desktopfile) except Exception as e: # IO or access error log.warning("Failed to remove autostart entry: %s", e) return False return True
Example #23
Source File: windows.py From Tautulli with GNU General Public License v3.0 | 4 votes |
def set_startup(): if plexpy.WIN_SYS_TRAY_ICON: plexpy.WIN_SYS_TRAY_ICON.change_tray_icons() startup_reg_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Run" exe = sys.executable if plexpy.FROZEN: args = [exe] else: args = [exe, plexpy.FULL_PATH] cmd = ' '.join(cmd_quote(arg) for arg in args).replace('python.exe', 'pythonw.exe').replace("'", '"') if plexpy.CONFIG.LAUNCH_STARTUP: try: winreg.CreateKey(winreg.HKEY_CURRENT_USER, startup_reg_path) registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, startup_reg_path, 0, winreg.KEY_WRITE) winreg.SetValueEx(registry_key, common.PRODUCT, 0, winreg.REG_SZ, cmd) winreg.CloseKey(registry_key) logger.info("Added Tautulli to Windows system startup registry key.") return True except WindowsError as e: logger.error("Failed to create Windows system startup registry key: %s", e) return False else: # Check if registry value exists try: registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, startup_reg_path, 0, winreg.KEY_ALL_ACCESS) winreg.QueryValueEx(registry_key, common.PRODUCT) reg_value_exists = True except WindowsError: reg_value_exists = False if reg_value_exists: try: winreg.DeleteValue(registry_key, common.PRODUCT) winreg.CloseKey(registry_key) logger.info("Removed Tautulli from Windows system startup registry key.") return True except WindowsError as e: logger.error("Failed to delete Windows system startup registry key: %s", e) return False