本文整理匯總了Python中winreg.DeleteValue方法的典型用法代碼示例。如果您正苦於以下問題:Python winreg.DeleteValue方法的具體用法?Python winreg.DeleteValue怎麽用?Python winreg.DeleteValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類winreg
的用法示例。
在下文中一共展示了winreg.DeleteValue方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: toggle_run_on_startup
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
def toggle_run_on_startup(self, is_checked):
if (self.platform == 'Windows'):
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
r'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run',
0, winreg.KEY_SET_VALUE)
if (is_checked):
path = sys.executable
winreg.SetValueEx(key, 'Blender Version Manager',
0, winreg.REG_SZ, path)
else:
try:
winreg.DeleteValue(key, 'Blender Version Manager')
except:
pass
key.Close()
self.settings.setValue('is_run_on_startup', is_checked)
示例2: path_cleanup
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
def path_cleanup():
''' Removes SIMNIBS from PATH '''
if sys.platform in ['linux', 'darwin']:
bashrc, backup_file = _get_bashrc()
if not os.path.isfile(bashrc):
print('Could not find bashrc file')
return
print('Removing SimNIBS install from PATH')
print(f'Backing up the bashrc file at {backup_file}')
_copy_and_log(bashrc, backup_file)
with open(backup_file, 'r') as fin:
with open(bashrc, 'w') as fout:
for line in fin:
if not re.search('simnibs', line, re.IGNORECASE):
fout.write(line)
else:
simnibs_env_vars = _get_win_simnibs_env_vars()
path = _get_win_path()
path = path.split(';')
path = [p for p in path if len(p) > 0]
for key, value in simnibs_env_vars.items():
# If the directory is in the PATH variable, remove it
path = [
os.path.normpath(p) for p in path if not (
os.path.normpath(value) in os.path.normpath(p))]
# Remove environment variable
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Environment', access=winreg.KEY_WRITE) as reg:
winreg.DeleteValue(reg, key)
# write out the PATH with SimNIBS removed
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Environment', access=winreg.KEY_WRITE) as reg:
path = ';'.join(path) + ';'
winreg.SetValueEx(reg,'Path', 0, winreg.REG_EXPAND_SZ, path)
示例3: __delitem__
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
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,))
示例4: uninstall
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
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
示例5: removestartup
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
def removestartup():
# check if it is linux
if os_type in OS.BSD_FAMILY:
# remove it
os.remove(home_address + "/.config/autostart/persepolis.desktop")
# check if it is mac OS
elif os_type == OS.OSX:
# OS X
if checkstartup():
os.system('launchctl unload ' + home_address +
"/Library/LaunchAgents/com.persepolisdm.plist")
os.remove(home_address +
"/Library/LaunchAgents/com.persepolisdm.plist")
# check if it is Windows
elif os_type == OS.WINDOWS:
if checkstartup():
# Connect to the startup path in Registry
key = winreg.OpenKey(
winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, winreg.KEY_ALL_ACCESS)
# remove persepolis from startup
winreg.DeleteValue(key, 'persepolis')
# Close connection
winreg.CloseKey(key)
示例6: delete_password
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
def delete_password(self, service, username):
"""Delete the password for the username of the service.
"""
try:
key_name = self._key_for_service(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)
示例7: set_value
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
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)))
示例8: _set_all_values
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
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)))
示例9: del_value
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
def del_value(self, key, value=''):
if self.no_restore is False:
try:
return winreg.DeleteValue(key, value)
except WindowsError as error:
return None
示例10: __remove_from_startup_programs
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
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
示例11: set_startup
# 需要導入模塊: import winreg [as 別名]
# 或者: from winreg import DeleteValue [as 別名]
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