This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author upendra-k14
Recipients lorenzogotuned, terry.reedy, upendra-k14
Date 2016-06-11.03:18:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465615081.0.0.12544407211.issue27051@psf.upfronthosting.co.za>
In-reply-to
Content
I am unable to print anything using winreg module. Does it require administrative privileges?

I am using this code sample :

import os
import errno
import winreg

proc_arch = os.environ['PROCESSOR_ARCHITECTURE'].lower()
try:
	proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
except KeyError:
	proc_arch64 = None
	pass

if proc_arch == 'x86' and not proc_arch64:
	arch_keys = {0}
elif proc_arch == 'x86' or proc_arch == 'amd64':
	arch_keys = {winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY}
else:
	raise Exception("Unhandled arch {}".format(proc_arch))
	
for arch_key in arch_keys:
	key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Python", 0, winreg.KEY_READ | arch_key)
	for i in range(0, winreg.QueryInfoKey(key)[0]):
		skey_name = winreg.EnumKey(key, i)
		skey = winreg.OpenKey(key, skey_name)
		try:
			print(winreg.QueryValueEx(skey, 'DisplayName')[0])
		except OSError as e:
			if e.errno == errno.ENOENT:
				pass
		finally:
			skey.Close()
History
Date User Action Args
2016-06-11 03:18:01upendra-k14setrecipients: + upendra-k14, terry.reedy, lorenzogotuned
2016-06-11 03:18:01upendra-k14setmessageid: <1465615081.0.0.12544407211.issue27051@psf.upfronthosting.co.za>
2016-06-11 03:18:00upendra-k14linkissue27051 messages
2016-06-11 03:18:00upendra-k14create