Python _winreg.KEY_WRITE Examples
The following are 23
code examples of _winreg.KEY_WRITE().
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: RegistryStorageProvider.py From AltFS with BSD 3-Clause "New" or "Revised" License | 6 votes |
def write_block(self, bucket_id, value_id, data=""): """Described in parent class""" try: value_name = self._get_value_name( bucket_id, value_id) except BucketValueMissingException: logger.debug( "value with id does not exist in specified bucket." + " generating a new value name for bucket id %s" % bucket_id) value_name = self._generate_value_name(bucket_id) logger.debug("generated a new value name in bucket id %s: %s" % ( bucket_id, value_name)) with self._get_bucket_key(bucket_id, _winreg.KEY_WRITE) as key: _winreg.SetValueEx(key, value_name, 0, _winreg.REG_BINARY, data) return RegistryStorageProvider.value_name_to_value_id(value_name)
Example #2
Source File: textext.py From inkscapeMadeEasy with GNU General Public License v3.0 | 6 votes |
def save(self): if USE_WINDOWS: import _winreg try: key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, self.keyname, sam=_winreg.KEY_SET_VALUE | _winreg.KEY_WRITE) except: key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, self.keyname) try: for k, v in self.values.iteritems(): _winreg.SetValueEx(key, str(k), 0, _winreg.REG_SZ, str(v)) finally: key.Close() else: d = os.path.dirname(self.filename) if not os.path.isdir(d): os.makedirs(d) f = open(self.filename, 'w') try: data = '\n'.join(["%s=%s" % (k,v) for k,v in self.values.iteritems()]) f.write(data) finally: f.close()
Example #3
Source File: util.py From byob with GNU General Public License v3.0 | 6 votes |
def registry_key(key, subkey, value): """ Create a new Windows Registry Key in HKEY_CURRENT_USER `Required` :param str key: primary registry key name :param str subkey: registry key sub-key name :param str value: registry key sub-key value Returns True if successful, otherwise False """ try: import _winreg reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, subkey, 0, _winreg.REG_SZ, value) _winreg.CloseKey(reg_key) return True except Exception as e: log(e) return False
Example #4
Source File: util.py From byob with GNU General Public License v3.0 | 6 votes |
def registry_key(key, subkey, value): """ Create a new Windows Registry Key in HKEY_CURRENT_USER `Required` :param str key: primary registry key name :param str subkey: registry key sub-key name :param str value: registry key sub-key value Returns True if successful, otherwise False """ try: import _winreg reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, subkey, 0, _winreg.REG_SZ, value) _winreg.CloseKey(reg_key) return True except Exception as e: log(e) return False
Example #5
Source File: util.py From byob with GNU General Public License v3.0 | 6 votes |
def registry_key(key, subkey, value): """ Create a new Windows Registry Key in HKEY_CURRENT_USER `Required` :param str key: primary registry key name :param str subkey: registry key sub-key name :param str value: registry key sub-key value Returns True if successful, otherwise False """ try: import _winreg reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, subkey, 0, _winreg.REG_SZ, value) _winreg.CloseKey(reg_key) return True except Exception as e: log(e) return False
Example #6
Source File: util.py From byob with GNU General Public License v3.0 | 6 votes |
def registry_key(key, subkey, value): """ Create a new Windows Registry Key in HKEY_CURRENT_USER `Required` :param str key: primary registry key name :param str subkey: registry key sub-key name :param str value: registry key sub-key value Returns True if successful, otherwise False """ try: import _winreg reg_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, subkey, 0, _winreg.REG_SZ, value) _winreg.CloseKey(reg_key) return True except Exception as e: log(e) return False
Example #7
Source File: Registry.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def __call__( self, key, subkey, valueName, action, keyType, newValue, disableParsing=False ): if not disableParsing: newValue = eg.ParseString(newValue) if not key: self.PrintError(self.text2.noKeyError) return 0 if not subkey: self.PrintError(self.text2.noSubkeyError) return 0 if not valueName: self.PrintError(self.text2.noValueNameError) return 0 #try to get handle try: if action == 0: regHandle = _winreg.CreateKey(key, subkey) else: regHandle = _winreg.OpenKey( key, subkey, 0, _winreg.KEY_WRITE | _winreg.KEY_READ ) except EnvironmentError, exc: if action != 1: eg.PrintError(self.text2.keyOpenError + ": " + str(exc)) return 0 #getting old value
Example #8
Source File: px.py From px with MIT License | 5 votes |
def install(): if check_installed() is False: runkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Run", 0, winreg.KEY_WRITE) winreg.SetValueEx(runkey, "Px", 0, winreg.REG_EXPAND_SZ, get_script_cmd()) winreg.CloseKey(runkey) pprint("Px installed successfully") else: pprint("Px already installed") sys.exit()
Example #9
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def Finish(self): """ This will be called inside the thread when it finishes. It will even be called if the thread exits through an exception. """ self.abort = True self.lock.acquire() if self.dll: self.dll.IR_Close(self.hwnd, 0); #print "Irremote is stopped" if self.timerInit : self.timerInit.cancel() #print "Init aborted" if self.hwnd: windll.user32.KillTimer(self.hwnd, 1) DestroyWindow(self.hwnd) UnregisterClass(self.wc.lpszClassName, self.hinst) if self.defaultPollTime != -1 : regHandle = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\hauppauge\IR', 0, _winreg.KEY_WRITE | _winreg.KEY_READ ) _winreg.SetValueEx( regHandle, 'PollRate', 0, _winreg.REG_DWORD, int(self.defaultPollTime) ) _winreg.CloseKey( regHandle ) self.lock.release()
Example #10
Source File: __init__.py From butterflow with MIT License | 5 votes |
def add_registry_keys(): for key in get_local_machine_registry_subkeys(KHRONOS_REG_PATH): if key is not None: key = RegistryKey(key[0], key[2], key[1]) if key in KEYS_NEEDED: KEYS_NEEDED.remove(key) else: # print("?: "+str(key)) pass # print("No keys left\nKeys to add: "+str(KEYS_NEEDED)) for key_needed in KEYS_NEEDED: try: try: subkey = winreg.CreateKeyEx(REG_HIVE, KHRONOS_REG_PATH, 0, winreg.KEY_CREATE_SUB_KEY) except WindowsError as error: print("Couldn't create subkeys at: %s\tReason: %s" % (KHRONOS_REG_PATH, error)) exit(1) finally: subkey.Close() with winreg.OpenKey(REG_HIVE, KHRONOS_REG_PATH, 0, winreg.KEY_WRITE) as key: winreg.SetValueEx(key, key_needed.name, 0, key_needed.data_type, key_needed.value) # print("+"+str(key_needed)) except WindowsError as error: print("Couldn't create (%s)\tReason: %s" % (key_needed, error)) exit(1) # TODO: How to Enumerate Vendor ICDs on Windows: https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/cl_khr_icd.txt#L68 # SEARCH_HIVE=winreg.HKEY_LOCAL_MACHINE
Example #11
Source File: persistence.py From Intensio-Obfuscator with MIT License | 5 votes |
def windows_persistence(): import _winreg from _winreg import HKEY_CURRENT_USER as HKCU run_key = r'Software\Microsoft\Windows\CurrentVersion\Run' bin_path = sys.executable try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, 'br', 0, _winreg.REG_SZ, bin_path) _winreg.CloseKey(reg_key) return True, 'HKCU Run registry key applied' except WindowsError: return False, 'HKCU Run registry key failed'
Example #12
Source File: persistence.py From Intensio-Obfuscator with MIT License | 5 votes |
def windows_persistence(): import _winreg from _winreg import HKEY_CURRENT_USER as HKCU run_key = r'Software\Microsoft\Windows\CurrentVersion\Run' bin_path = sys.executable try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, 'br', 0, _winreg.REG_SZ, bin_path) _winreg.CloseKey(reg_key) return True, 'HKCU Run registry key applied' except WindowsError: return False, 'HKCU Run registry key failed'
Example #13
Source File: persistence.py From Intensio-Obfuscator with MIT License | 5 votes |
def srOXhtoTWVPOQTAFQsEjXglmECQYMydH(): import _winreg from _winreg import HKEY_CURRENT_USER as HKCU ejhEOFlPViXKPUHKJhcSyqqQjSUcagli = r'Software\Microsoft\Windows\CurrentVersion\Run' MtcFrCNqZIqaQyIxdGTfhTosybVfegHt = sys.executable try: SCyNiWCgkJlizIsydlByszPSbHjrsmmo = _winreg.OpenKey(HKCU, ejhEOFlPViXKPUHKJhcSyqqQjSUcagli, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(SCyNiWCgkJlizIsydlByszPSbHjrsmmo, 'br', 0, _winreg.REG_SZ, MtcFrCNqZIqaQyIxdGTfhTosybVfegHt) _winreg.CloseKey(SCyNiWCgkJlizIsydlByszPSbHjrsmmo) return True, 'HKCU Run registry key applied' except WindowsError: return False, 'HKCU Run registry key failed'
Example #14
Source File: persistence.py From Intensio-Obfuscator with MIT License | 5 votes |
def windows_persistence(): import _winreg from _winreg import HKEY_CURRENT_USER as HKCU run_key = r'Software\Microsoft\Windows\CurrentVersion\Run' bin_path = sys.executable try: reg_key = _winreg.OpenKey(HKCU, run_key, 0, _winreg.KEY_WRITE) _winreg.SetValueEx(reg_key, 'br', 0, _winreg.REG_SZ, bin_path) _winreg.CloseKey(reg_key) return True, 'HKCU Run registry key applied' except WindowsError: return False, 'HKCU Run registry key failed'
Example #15
Source File: ext_server_uacamola.py From uac-a-mola with GNU General Public License v3.0 | 5 votes |
def open_key(self, key, subkey): """ Opens a key """ try: return winreg.OpenKey(key, subkey, 0, winreg.KEY_WRITE) except: return None
Example #16
Source File: winreg.py From uac-a-mola with GNU General Public License v3.0 | 5 votes |
def open_key(self, key, subkey): """ Opens a key """ try: return winreg.OpenKey(key, subkey, 0, winreg.KEY_WRITE) except: return None
Example #17
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 #18
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 #19
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 #20
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 #21
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 #22
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
Example #23
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def PostInit( self ) : self.lock.acquire() if self.abort : self.lock.release() return self.timerInit = Timer( 60.0, self.OnPostInitTimeOut) # Init timeout timer self.timerInit.start() returnVal = False if ( not self.useDefaultPollTime ) : regHandle = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\hauppauge\IR', 0, _winreg.KEY_WRITE | _winreg.KEY_READ ) self.defaultPollTime = int( _winreg.QueryValueEx(regHandle, 'PollRate')[0] ) _winreg.SetValueEx( regHandle, 'PollRate', 0, _winreg.REG_DWORD, int(self.pollTime) ) returnVal = self.IR_Open(self.hwnd, 0, 0, 0); _winreg.SetValueEx( regHandle, 'PollRate', 0, _winreg.REG_DWORD, int(self.defaultPollTime) ) _winreg.CloseKey( regHandle ) self.defaultPollTime = -1 else : returnVal = self.IR_Open(self.hwnd, 0, 0, 0); self.timerInit.cancel() if not self.initTerminated : if not returnVal and not self.initTerminated : self.plugin.PrintError("Couldn't start the Hauppauge remote control") self.Stop() self.plugin.TriggerEvent("InitError") else : #print "Irremote is started" pass del self.timerInit self.timerInit = None self.lock.release()