def test_safe_mode_blocked_by_policy(self): if platform.system() != 'Windows': return reg_policies = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Policies", 0, winreg.KEY_WRITE) reg_mozilla = winreg.CreateKeyEx(reg_policies, "Mozilla", 0, winreg.KEY_WRITE) reg_firefox = winreg.CreateKeyEx(reg_mozilla, "Firefox", 0, winreg.KEY_WRITE) winreg.SetValueEx(reg_firefox, "DisableSafeMode", 0, winreg.REG_DWORD, 1) self.marionette.instance.app_args.append("-safe-mode") self.marionette.quit() self.marionette.start_session() with self.marionette.using_context("chrome"): safe_mode = self.marionette.execute_script(""" Cu.import("resource://gre/modules/Services.jsm"); return Services.appinfo.inSafeMode; """) self.assertFalse(safe_mode, "Safe Mode has been enabled") winreg.CloseKey(reg_firefox) winreg.DeleteKey(reg_mozilla, "Firefox") winreg.CloseKey(reg_mozilla) winreg.DeleteKey(reg_policies, "Mozilla") winreg.CloseKey(reg_policies)
def reg_create_tree(key, sub_key, flags): """ Creates new registry key if key does not exist, or opens key if key exists. :param key: Registry key. May be winreg.HKEY_* value. :param sub_key: Path of the subkey. :param flags: Additional access flags. :return: Returns handle to registry if successful. """ # first, try to open full path ret_key = None try: ret_key = winreg.CreateKeyEx(key, sub_key, 0, winreg.KEY_SET_VALUE | flags) return ret_key except OSError: # if this failed we need to create more than one key pass # if that fails, create path in steps path_split = sub_key.split('\\') for i in range(len(path_split)): try: ret_key = winreg.CreateKeyEx(key, '\\'.join(path_split[:i + 1]), 0, winreg.KEY_SET_VALUE | flags) except OSError: raise ct.WinError() return ret_key
def make_sub_command(command_name, command, command_icon): subkey = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\{0}'.format(command_name) hkey = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, subkey, 0, winreg.KEY_SET_VALUE) winreg.SetValueEx(hkey, 'Icon', 0, winreg.REG_SZ, CONFIG_DIR + '\\{0}'.format(command_icon)) subkey = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\{0}\command'.format(command_name) hkey = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, subkey, 0, winreg.KEY_SET_VALUE) winreg.SetValueEx(hkey, '', 0, winreg.REG_SZ, command)
def _registerFileAssociation(extension, exePath, associate, mimetype): try: with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Classes\\%s" % associate, 0, winreg.KEY_WRITE) as k: #winreg.SetValueEx(k, None, 0, winreg.REG_SZ, "") with winreg.CreateKeyEx(k, "DefaultIcon", 0, winreg.KEY_WRITE) as k2: winreg.SetValueEx(k2, None, 0, winreg.REG_SZ, "@{exePath},1".format(exePath=exePath)) with winreg.CreateKeyEx(k, "shell\\open\\command", 0, winreg.KEY_WRITE) as k2: winreg.SetValueEx( k2, None, 0, winreg.REG_SZ, u"\"{exePath}\" \"%1\"".format(exePath=exePath)) with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Classes\\%s" % extension, 0, winreg.KEY_WRITE) as k: winreg.SetValueEx(k, None, 0, winreg.REG_SZ, associate) if mimetype != None: winreg.SetValueEx(k, "Content Type", 0, winreg.REG_SZ, mimetype) k2 = winreg.CreateKeyEx(k, "OpenWithProgids\\%s" % associate, 0, winreg.KEY_WRITE) winreg.CloseKey(k2) shellapi.SHChangeNotify(shellapi.SHCNE_ASSOCCHANGED, shellapi.SHCNF_IDLIST, None, None) return True except WindowsError as e: log = logging.getLogger("%s.fileAssoc" % (constants.LOG_PREFIX)) log.error("file Association faild - %s" % (str(e))) return False
def create_registry_keys(path): with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path + "\\Device Parameters", 0, winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY) as key: winreg.CreateKeyEx(key, "Interrupt Management", 0, winreg.KEY_WRITE) with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path + "\\Device Parameters\\Interrupt Management", 0, winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY) as key2: winreg.CreateKeyEx(key2, "Affinity Policy", 0, winreg.KEY_WRITE) winreg.CreateKeyEx(key2, "MessagesignaledInterruptProperties", 0, winreg.KEY_WRITE)
def _winreg_read(self, base, path, key): try: if self.is_win_x64: hkey = winreg.CreateKeyEx(base, path, 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY) else: hkey = winreg.CreateKeyEx(base, path, 0, winreg.KEY_READ) value = winreg.QueryValueEx(hkey, key) return value except OSError: return None
def write_registry(bank_id, bank_name, bank_path): logger.debug("Writing registry for {} ({}) @ {}".format( bank_name, bank_id, bank_path)) bank_path_parent = str(Path(bank_path).parent) dict_bank = dict(BankName=bank_name.replace(' ', '_'), DRP="000055", DefaultStyleID="gf22245e-19b1-40e1-a37a-699eaa5b4a1d", Key="2ef256c28b85f2f16329acb0a9ba2ea4", Name=bank_name, Path=bank_path_parent, Date="BMRDG7KZR3ZB27DE") dict_version = dict(Major=4, Minor=0, Revision=0) # registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) # install config section config_reg_path = r"SOFTWARE\VOCALOID5\Voice\Components\{}".format(bank_id) logger.debug("Writing {}".format(config_reg_path)) try: config_key = winreg.OpenKeyEx( winreg.HKEY_LOCAL_MACHINE, config_reg_path, 0, winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS) except Exception as ex: config_key = winreg.CreateKeyEx( winreg.HKEY_LOCAL_MACHINE, config_reg_path, 0, winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS) # set one key for key, value in dict_bank.items(): logger.debug("Setup key | {} : {}".format(key, value)) winreg.SetValueEx(config_key, key, 0, winreg.REG_SZ, value) winreg.CloseKey(config_key) # install version section version_reg_path = r'SOFTWARE\VOCALOID5\Voice\Components\{}\Version'.format( bank_id) logger.debug("Writing {}".format(version_reg_path)) winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, version_reg_path) try: version_key = winreg.OpenKeyEx( winreg.HKEY_LOCAL_MACHINE, version_reg_path, 0, winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS) except Exception as ex: version_key = winreg.CreateKeyEx( winreg.HKEY_LOCAL_MACHINE, version_reg_path, 0, winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS) for key, value in dict_version.items(): logger.debug("Setup key | {} : {}".format(key, value)) winreg.SetValueEx(version_key, key, 0, winreg.REG_DWORD, value) winreg.CloseKey(version_key) logger.debug("Successfully writing all changes into registry")
def register(scheme, application=None): if application == None: application = globalVars.app.getAppPath() try: with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, "software\\classes\\" + scheme) as k1: winreg.SetValueEx(k1, None, 0, winreg.REG_SZ, scheme) winreg.SetValueEx(k1, "URL Protocol", 0, winreg.REG_SZ, "") with winreg.CreateKeyEx(k1, "shell") as k2: with winreg.CreateKeyEx(k2, "open") as k3: with winreg.CreateKeyEx(k3, "command") as k4: winreg.SetValueEx(k4, None, 0, winreg.REG_SZ, r'"%s" %%1' % application) return True except WindowsError as e: log.error(traceback.format_exc()) return False
def install(): for key in reg_classes: root = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, sub_key=rf'{key}\shell', access=winreg.KEY_CREATE_SUB_KEY) command_pdf = winreg.CreateKeyEx(root, r'EZNO Convert to PDF\command', access=winreg.KEY_SET_VALUE) winreg.SetValueEx(command_pdf, '', 0, winreg.REG_SZ, gui_no_options_cmd) command_gui = winreg.CreateKeyEx(root, r'EZNO Convert to...\command', access=winreg.KEY_SET_VALUE) winreg.SetValueEx(command_gui, '', 0, winreg.REG_SZ, gui_with_options_cmd)
def write(key: str, content: Union[str, Dict[Optional[str], str]]) -> bool: """ Write the specified key in the Current User registry. If `content` is a string, it will be set as the default value of the registry key. If `content` is a dictionary, each key/value in `content` will be a value name/value data in the key. If the dictionary key is `None`, the data will be set as the default value of the registry key. Return `True` if the write was successful, `False` otherwise. """ if isinstance(content, str): content = {None: content} try: with winreg.CreateKeyEx(HKCU, key) as handle: for name, data in content.items(): # TODO: remove the comment when https://github.com/python/typeshed/pull/4663 is done winreg.SetValueEx(handle, name, 0, winreg.REG_SZ, data) # type: ignore log.info(f"Wrote {key!r}: {content!r}") except OSError: log.exception(f"Couldn't write {key!r}") return False return True
def reg_add(subkey, name, valtype, value): try: reg_key = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, subkey, 0) with reg_key: winreg.SetValueEx(reg_key, name, 0, valtype, value) except Exception as ex: logger.error(f'cannot add registry key {subkey}: {ex}')
def set_winreg_fromlocalmachine(path, name, value, overwrite=False, dword=True): #needed only for windows if "window" not in os_name().lower(): return #ignore and return incase winreg isn't available try: import winreg except ImportError: return key_type = winreg.REG_DWORD if dword else winreg.REG_SZ try: current_value = get_winreg_fromlocalmachine(winreg, path, name) if current_value and (not overwrite): return current_value k = winreg.CreateKeyEx( winreg.HKEY_LOCAL_MACHINE, path, 0, winreg.KEY_CREATE_SUB_KEY | winreg.KEY_WOW64_64KEY) winreg.CloseKey(k) with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path, 0, winreg.KEY_WRITE) as registry_entry: winreg.SetValueEx(registry_entry, name, 0, key_type, value) return value except (WindowsError, OSError): return None
def SetregistryDWordWOW64(regKey, key, Val): try: hkey = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, regKey, 0, winreg.KEY_WOW64_64KEY | winreg.KEY_ALL_ACCESS) winreg.SetValueEx(hkey, key, 0, winreg.REG_DWORD, Val) hkey.Close() except WindowsError: print('error SetregistryDWordWOW64')
def SetregistryString(regKey, key, Val): try: hkey = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, regKey, 0, winreg.KEY_ALL_ACCESS) winreg.SetValueEx(hkey, key, 0, winreg.REG_SZ, Val) hkey.Close() except WindowsError: print('error SetregistryString')
def create_registry_entry(dummy_registry_keys): aReg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) keys_created = 0 keys_present = 0 for entry in dummy_registry_keys: if len( entry ) < 4 or entry[:4] != "HKLM" or ":" in entry or "\\" not in entry: exit( "Only HKLM registry keys are supported. Invalid registry keys in file: " + entry) else: entry = '\\'.join(entry.split("\\")[1:]) if not is_entry_in_registry(aReg, entry): try: # The flag KEY_WOW64_64KEY is needed when using Python-32 bit winreg.CreateKeyEx(aReg, entry, 0, access=winreg.KEY_WOW64_64KEY) keys_created += 1 except Exception as e: print("Failed to create the registry key: " + entry + " " + str(e)) else: keys_present += 1 print( str(keys_created) + " keys created, " + str(keys_present) + " keys already present")
def disable_sleep_hibernate(): with winreg.CreateKeyEx( winreg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", 0, winreg.KEY_ALL_ACCESS, ) as key: winreg.SetValueEx(key, "HiberbootEnabled", 0, winreg.REG_DWORD, 0) commands = [ lambda x: f"powercfg /set{x}valueindex scheme_current sub_buttons lidaction 0", lambda x: f"powercfg /x -standby-timeout-{x} 0", lambda x: f"powercfg /x -hibernate-timeout-{x} 0", lambda x: f"powercfg /x -disk-timeout-{x} 0", lambda x: f"powercfg /x -monitor-timeout-{x} 0", lambda x: f"powercfg /x -standby-timeout-{x} 0", ] for x in ["ac", "dc"]: for i in commands: subprocess.run(i(x), capture_output=True, shell=True) subprocess.run("powercfg -S SCHEME_CURRENT", capture_output=True, shell=True)
def SetregistryString32(regKey, key, Val): try: hkey = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, regKey, 0, winreg.KEY_ALL_ACCESS) winreg.SetValueEx(hkey, key, 0, winreg.REG_SZ, Val) hkey.Close() except WindowsError: print('error SetregistryString32')
def testSandboxSecurity(self): with contextlib.ExitStack() as stack: port = 12395 sock = stack.enter_context( socket.socket(socket.AF_INET, socket.SOCK_STREAM)) sock.bind(("", port)) sock.listen() sub_key = "Software\\SandboxTest" key = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, sub_key, access=winreg.KEY_ALL_ACCESS) winreg.SetValueEx(key, "foo", 0, winreg.REG_SZ, "bar") winreg.FlushKey(key) stack.callback(winreg.DeleteKey, winreg.HKEY_LOCAL_MACHINE, sub_key) stack.callback(winreg.CloseKey, key) stack.callback(winreg.DeleteValue, key, "foo") args = [ sys.executable, "-m", "grr_response_client.unprivileged.windows.sandbox_unprivileged_test_lib", "--localhost_port", str(port), "--registry_sub_key", sub_key ] p = process.Process(args, []) exit_code = p.Wait() self.assertEqual(exit_code, 0)
def write_config(self, work_path, error_count=5): with winreg.CreateKeyEx(self.__root__, r'SOFTWARE\ToGeek\file_express') as key: winreg.SetValueEx(key, 'work_path', 0, winreg.REG_SZ, work_path) winreg.SetValueEx(key, 'error_count', 0, winreg.REG_DWORD, error_count) self.load_config()
def register(self): """ Registers the environment into the windows registry. :note: We're explictly writing the environment to the registry to facilitate sharing. See `How to share pyproj across team with custom environments <https://pytools.codeplex.com/workitem/2765>`_ for motivation. """ hive, key, flag = self.__ptvs_interpreter_key__ tag = self.Description keyvalues = { os.path.join(key, tag): { 'SysArchitecture': self.Architecture, 'SysVersion': self.Version, 'DisplayName': self.Description, 'PathEnvironmentVariable': 'PYTHONPATH' }, os.path.join(key, tag, 'InstallPath'): { 'ExecutablePath': self.InterpreterAbsPath, 'WindowedExecutablePath': self.WindowsInterpreterAbsPath, } } try: for key, values in keyvalues.items(): with winreg.CreateKeyEx(hive, key, access=winreg.KEY_WRITE | flag) as regkey: for k, v in values.items(): winreg.SetValueEx(regkey, k, 0, winreg.REG_SZ, v) except WindowsError: return False self.ID = "Global|VisualStudio|{}".format(company, tag) return True
def default(self): '''Change to default the name of the PC in the network''' with open('NAME.temp', 'rt') as file: self.NAME_PC = file.readline() with winreg.CreateKeyEx(self.user, self.path) as key: winreg.SetValueEx(key, "Hostname", 0, self.valor, self.NAME_PC) winreg.SetValueEx(key, "NV Hostname", 0, self.valor, self.NAME_PC)
def __init__(self): super().__init__() self._connection = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) self._registry = winreg.CreateKeyEx(self._connection, "Software\TTS Manager", 0, winreg.KEY_ALL_ACCESS) try: self._locationIsUser = "******" == winreg.QueryValueEx( self._registry, "locationIsUser")[0] except FileNotFoundError as e: self._locationIsUser = True try: self._TTSLocation = os.path.normpath( winreg.QueryValueEx(self._registry, "TTSLocation")[0]) except FileNotFoundError as e: self._TTSLocation = "" try: self._defaultSaveLocation = winreg.QueryValueEx( self._registry, "defaultSaveLocation")[0] except FileNotFoundError as e: self._defaultSaveLocation = "" try: self._firstRun = "True" == winreg.QueryValueEx( self._registry, "firstRun")[0] except FileNotFoundError as e: self._firstRun = True
def registerEaseOfAccess(installDir): with winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, easeOfAccess.APP_KEY_PATH, 0, winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY) as appKey: winreg.SetValueEx(appKey, "ApplicationName", None, winreg.REG_SZ, versionInfo.name) winreg.SetValueEx(appKey, "Description", None, winreg.REG_SZ, versionInfo.longName) if easeOfAccess.canConfigTerminateOnDesktopSwitch: winreg.SetValueEx( appKey, "Profile", None, winreg.REG_SZ, '<HCIModel><Accommodation type="severe vision"/></HCIModel>') winreg.SetValueEx(appKey, "SimpleProfile", None, winreg.REG_SZ, "screenreader") winreg.SetValueEx(appKey, "ATExe", None, winreg.REG_SZ, "nvda.exe") winreg.SetValueEx(appKey, "StartExe", None, winreg.REG_SZ, os.path.join(installDir, u"nvda.exe")) winreg.SetValueEx(appKey, "StartParams", None, winreg.REG_SZ, "--ease-of-access") winreg.SetValueEx(appKey, "TerminateOnDesktopSwitch", None, winreg.REG_DWORD, 0) else: # We don't want NVDA to appear in EoA because # starting NVDA from there won't work in this case. # We can do this by not setting Profile and SimpleProfile. # NVDA can still change the EoA logon settings. winreg.SetValueEx(appKey, "ATExe", None, winreg.REG_SZ, "nvda_eoaProxy.exe") winreg.SetValueEx(appKey, "StartExe", None, winreg.REG_SZ, os.path.join(installDir, u"nvda_eoaProxy.exe"))
def __init__(self): self.connection = winreg.ConnectRegistry( None, winreg.HKEY_CURRENT_USER) self.registry = winreg.CreateKeyEx( self.connection, "Software\\TTS Manager", 0, winreg.KEY_ALL_ACCESS) self.changed = False try: self._locationIsUser = "******" == winreg.QueryValueEx( self.registry, "locationIsUser")[0] except FileNotFoundError as e: #logger().info("locationIsUser missing: {}".format(e)) self._locationIsUser = True try: self._TTSLocation = winreg.QueryValueEx( self.registry, "TTSLocation")[0] except FileNotFoundError as e: #logger().info("TTSLocation missing: {}".format(e)) self._TTSLocation = "" try: self._defaultSaveLocation = winreg.QueryValueEx( self.registry, "defaultSaveLocation")[0] except FileNotFoundError as e: #logger().info("defaultSaveLocation missing: {}".format(e)) self._defaultSaveLocation = "" try: self._firstRun = "True" == winreg.QueryValueEx( self.registry, "firstRun")[0] except FileNotFoundError as e: #logger().info("firstRun missing: {}".format(e)) self._firstRun = True
def func(): try: regKey = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, r'Software\\Roblox\\RobloxStudio', access=winreg.KEY_WRITE) except: regKey = winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, r'Software\\Roblox\\RobloxStudio', access=winreg.KEY_WRITE) winreg.SetValueEx(regKey, r'ContentFolder', 0, winreg.REG_SZ, content_folder) winreg.CloseKey(regKey)
def _reg_update_from_op_table(key, may_sub_key, child_op_table): # (key, may_sub_key) :: MayKeyPair if child_op_table is OP_READ or child_op_table is OP_NOT_FOUND: pass elif child_op_table is OP_DELETE: #winreg.DeleteKey(key, may_sub_key)#??? if may_sub_key is None: raise WindowsError('winreg.DeleteKey(key, None)') sub_key = may_sub_key #winreg.DeleteKey(key, sub_key) _reg_delete_key_tree(key, sub_key) else: child_table = child_op_table key_table, value_table = child_table if may_sub_key is None: # "with root_hkey_constant as child_key" may cause error?? child_key = key _reg_update_from_table(child_key, child_table) else: sub_key = may_sub_key try: #child_key = winreg.CreateKeyEx(key, may_sub_key) child_key = winreg.CreateKeyEx(key, sub_key) except WindowsError: print(key) print(repr(may_sub_key)) raise else: with child_key: _reg_update_from_table(child_key, child_table)
def __call__(self, *args, **kwargs): PythonBatchCommandBase.__call__(self, *args, **kwargs) try: self.key_handle = winreg.CreateKeyEx(getattr(winreg, self.top_key), self.sub_key, 0, (self.reg_view_num_to_const[self.reg_num_bits] | self.permission_flag)) if self.value_data is not None: winreg.SetValueEx(self.key_handle, None, 0, getattr(winreg, 'REG_SZ'), self.value_data) finally: self._close_key()
def reg_edit(key_name, reg_dict): # TODO: lower priv than winreg.KEY_ALL_ACCESS? key = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, key_name, reserved=0, access=winreg.KEY_ALL_ACCESS) for reg_name, (reg_type, reg_data) in reg_dict.items(): winreg.SetValueEx(key, reg_name, 0, reg_type, reg_data)
def _AccessRootKey(self): if self._root_key is None: # Don't use winreg.KEY_WOW64_64KEY since it breaks on Windows 2000 self._root_key = winreg.CreateKeyEx(self._key_spec.winreg_hive, self._key_spec.path, 0, winreg.KEY_ALL_ACCESS) self.parsed = self._key_spec.path return self._root_key
def registerInstallation(installDir: str, startMenuFolder: str, shouldCreateDesktopShortcut: bool, startOnLogonScreen: bool, configInLocalAppData: bool = False) -> None: calculatedUninstallerRegInfo = uninstallerRegInfo.copy() # EstimatedSize is in KiB estimatedSize = getDirectorySize(installDir) log.debug(f"Estimated install size {estimatedSize}") calculatedUninstallerRegInfo.update(EstimatedSize=estimatedSize // 1024) with winreg.CreateKeyEx( winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\NVDA", 0, winreg.KEY_WRITE) as k: for name, value in calculatedUninstallerRegInfo.items(): if isinstance(value, int): winreg.SetValueEx(k, name, None, winreg.REG_DWORD, value) else: winreg.SetValueEx(k, name, None, winreg.REG_SZ, value.format(installDir=installDir)) with winreg.CreateKeyEx( winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\nvda.exe", 0, winreg.KEY_WRITE) as k: winreg.SetValueEx(k, "", None, winreg.REG_SZ, os.path.join(installDir, "nvda.exe")) with winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, config.RegistryKey.NVDA.value, 0, winreg.KEY_WRITE) as k: winreg.SetValueEx(k, "startMenuFolder", None, winreg.REG_SZ, startMenuFolder) if configInLocalAppData: winreg.SetValueEx(k, config.CONFIG_IN_LOCAL_APPDATA_SUBKEY, None, winreg.REG_DWORD, int(configInLocalAppData)) registerEaseOfAccess(installDir) if startOnLogonScreen is not None: config._setStartOnLogonScreen(startOnLogonScreen) NVDAExe = os.path.join(installDir, u"nvda.exe") slaveExe = os.path.join(installDir, u"nvda_slave.exe") try: _updateShortcuts(NVDAExe, installDir, shouldCreateDesktopShortcut, slaveExe, startMenuFolder) except Exception: log.error("Error while creating shortcuts", exc_info=True) registerAddonFileAssociation(slaveExe)