Python winreg.QueryValue() Examples

The following are 16 code examples of winreg.QueryValue(). 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: utils.py    From stata_kernel with GNU General Public License v3.0 6 votes vote down vote up
def win_find_path():
    import winreg
    reg = winreg.ConnectRegistry(None, winreg.HKEY_CLASSES_ROOT)
    subkeys = [
        r'Stata16Do\shell\do\command', r'Stata15Do\shell\do\command',
        r'Stata14Do\shell\do\command', r'Stata13Do\shell\do\command',
        r'Stata12Do\shell\do\command']

    fpath = ''
    for subkey in subkeys:
        try:
            key = winreg.OpenKey(reg, subkey)
            fpath = winreg.QueryValue(key, None).split('"')[1]
        except FileNotFoundError:
            pass
        if fpath:
            break

    return fpath 
Example #2
Source File: UnrealManagerWindows.py    From ue4cli with MIT License 6 votes vote down vote up
def getGenerateScript(self):
		
		# Under Windows, GenerateProjectFiles.bat only exists for source builds of the engine
		batFile = self.getEngineRoot() + '\\Engine\\Build\\BatchFiles\\GenerateProjectFiles.bat'
		if os.path.exists(batFile):
			return batFile
		
		# For versions of the engine installed using the launcher, we need to query the shell integration
		# to determine the location of the Unreal Version Selector executable, which generates VS project files
		try:
			key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, 'Unreal.ProjectFile\\shell\\rungenproj\\command')
			if key:
				command = winreg.QueryValue(key, None)
				if len(command) > 0:
					
					# Write the command to run UnrealVersionSelector.exe to our own batch file
					customBat = os.path.join(self._customBatchScriptDir(), 'GenerateProjectFiles.bat')
					Utility.writeFile(customBat, command.replace('"%1"', '%1') + '\r\n')
					return customBat
		except:
			pass
		
		raise UnrealManagerException('could not detect the location of GenerateProjectFiles.bat or UnrealVersionSelector.exe.\nThis typically indicates that .uproject files are not correctly associated with UE4.') 
Example #3
Source File: edge.py    From NSC_BUILDER with MIT License 6 votes vote down vote up
def _find_edge_win():
    import winreg as reg
    reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe'

    for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
        try:
            reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
            edge_path = reg.QueryValue(reg_key, None)
            reg_key.Close()
            if not os.path.isfile(edge_path):
                continue
        except WindowsError:
            edge_path = None
        else:
            break

    return edge_path 
Example #4
Source File: chrome.py    From NSC_BUILDER with MIT License 6 votes vote down vote up
def _find_chrome_win():
    import winreg as reg
    reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

    for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
        try:
            reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
            chrome_path = reg.QueryValue(reg_key, None)
            reg_key.Close()
            if not os.path.isfile(chrome_path):
                continue
        except WindowsError:
            chrome_path = None
        else:
            break

    return chrome_path 
Example #5
Source File: chrome.py    From Eel with MIT License 5 votes vote down vote up
def _find_chrome_win():
    import winreg as reg
    reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

    for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
        try:
            reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
            chrome_path = reg.QueryValue(reg_key, None)
            reg_key.Close()
            if not os.path.isfile(chrome_path):
                continue
        except WindowsError:
            chrome_path = None
        else:
            break

    return chrome_path 
Example #6
Source File: Utils.py    From 802.11ah-ns3 with GNU General Public License v2.0 5 votes vote down vote up
def get_registry_app_path(key,filename):
	if not winreg:
		return None
	try:
		result=winreg.QueryValue(key,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s.exe"%filename[0])
	except WindowsError:
		pass
	else:
		if os.path.isfile(result):
			return result 
Example #7
Source File: Utils.py    From royal-chaos with MIT License 5 votes vote down vote up
def get_registry_app_path(key,filename):
	if not winreg:
		return None
	try:
		result=winreg.QueryValue(key,"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s.exe"%filename[0])
	except WindowsError:
		pass
	else:
		if os.path.isfile(result):
			return result 
Example #8
Source File: get_win_browser.py    From PyMicroChat with GNU General Public License v3.0 5 votes vote down vote up
def get_browser_path():
    paths_dict = {}
    for name in BROWSER_PATH:
        handler = winreg.OpenKey(
            winreg.HKEY_LOCAL_MACHINE, BROWSER_PATH[name], access=winreg.KEY_READ)
        abs_path = winreg.QueryValue(handler, None)
        # print(abs_path)
        paths_dict[name] = abs_path
    return paths_dict 
Example #9
Source File: browsers.py    From tydesk with GNU General Public License v3.0 5 votes vote down vote up
def find_chrome_win():
  import winreg as reg
  reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

  for install_type in reg.HKEY_LOCAL_MACHINE, reg.HKEY_CURRENT_USER:
    try:
      reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
      chrome_path = reg.QueryValue(reg_key, None)
      reg_key.Close()
    except WindowsError:
      pass

  return chrome_path 
Example #10
Source File: browsers.py    From tydesk with GNU General Public License v3.0 5 votes vote down vote up
def find_firefox_win():
  import winreg as reg
  reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe'

  for install_type in reg.HKEY_LOCAL_MACHINE, reg.HKEY_CURRENT_USER:
    try:
      reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
      firefox_path = reg.QueryValue(reg_key, None)
      reg_key.Close()
    except WindowsError:
      pass

  return firefox_path 
Example #11
Source File: running_config_page.py    From thonny with MIT License 5 votes vote down vote up
def _get_interpreters_from_windows_registry(self):
        # https://github.com/python/cpython/blob/master/Tools/msi/README.txt
        import winreg

        result = set()
        for key in [winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER]:
            for version in [
                "3.5",
                "3.5-32",
                "3.5-64",
                "3.6",
                "3.6-32",
                "3.6-64",
                "3.7",
                "3.7-32",
                "3.7-64",
                "3.8",
                "3.8-32",
                "3.8-64",
            ]:
                try:
                    for subkey in [
                        "SOFTWARE\\Python\\PythonCore\\" + version + "\\InstallPath",
                        "SOFTWARE\\Python\\PythonCore\\Wow6432Node\\" + version + "\\InstallPath",
                    ]:
                        dir_ = winreg.QueryValue(key, subkey)
                        if dir_:
                            path = os.path.join(dir_, WINDOWS_EXE)
                            if os.path.exists(path):
                                result.add(path)
                except Exception:
                    pass

        return result 
Example #12
Source File: mu_nsist.py    From mu with GNU General Public License v3.0 5 votes vote down vote up
def find_makensis_win():
    """Locate makensis.exe on Windows by querying the registry"""
    try:
        nsis_install_dir = winreg.QueryValue(
            winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\NSIS"
        )
    except OSError:
        nsis_install_dir = winreg.QueryValue(
            winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\NSIS"
        )

    return pjoin(nsis_install_dir, "makensis.exe") 
Example #13
Source File: flaskwebgui.py    From flaskwebgui with MIT License 5 votes vote down vote up
def find_chrome_win(self):
        import winreg as reg
        reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

        for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
            try:
                reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
                chrome_path = reg.QueryValue(reg_key, None)
                reg_key.Close()
            except WindowsError:
                chrome_path = None
            else:
                break

        return chrome_path 
Example #14
Source File: flaskwebgui.py    From flaskwebgui with MIT License 5 votes vote down vote up
def find_chrome_win(self):
        import winreg as reg
        reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

        for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
            try:
                reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
                chrome_path = reg.QueryValue(reg_key, None)
                reg_key.Close()
            except WindowsError:
                chrome_path = None
            else:
                break

        return chrome_path 
Example #15
Source File: flaskwebgui.py    From flaskwebgui with MIT License 5 votes vote down vote up
def find_chrome_win(self):
        import winreg as reg
        reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

        for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
            try:
                reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
                chrome_path = reg.QueryValue(reg_key, None)
                reg_key.Close()
            except WindowsError:
                chrome_path = None
            else:
                break

        return chrome_path 
Example #16
Source File: flaskwebgui.py    From flaskwebgui with MIT License 5 votes vote down vote up
def find_chrome_win(self):
        import winreg as reg
        reg_path = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'

        for install_type in reg.HKEY_CURRENT_USER, reg.HKEY_LOCAL_MACHINE:
            try:
                reg_key = reg.OpenKey(install_type, reg_path, 0, reg.KEY_READ)
                chrome_path = reg.QueryValue(reg_key, None)
                reg_key.Close()
            except WindowsError:
                chrome_path = None
            else:
                break

        return chrome_path