Answer the question
In order to leave comments, you need to log in
Works in CMD but doesn't work in Python?
Tell me why the request in Python may not work, it gives the error "the specified key or parameter in the registry cannot be found"
Python:
import subprocess
keyPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI"
output = subprocess.run(["reg","query",keyPath,"/v","LastLoggedOnDisplayName"])
print(output.stdout)
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" /v LastLoggedOnDisplayName
Answer the question
In order to leave comments, you need to log in
import subprocess
keyPath = r'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI'
output = subprocess.run(
['reg', 'query', keyPath, '/reg:64', '/v', 'LastLoggedOnDisplayName'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='cp866')
print('stdout:', output.stdout)
print('stderr:', output.stderr)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question