Jump to content

Blank Record Reading.


Go to solution Solved by Musashi,

Recommended Posts

Posted

Good afternoon everyone,

I would like to know why not return the correct value?

Where am I going wrong in this simple function, even running as an administrator. And even copying the example from AutoIt Help.

Or if anyone has another idea how to get the username (and not the login) I would appreciate it.

Could you please teach me?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;#RequireAdmin

Local $sFilePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI", "LastLoggedOnDisplayName")
MsgBox($MB_SYSTEMMODAL, "", "Result: " & $sFilePath)

;RegTests
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData\1
;or
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI

 

Posted (edited)

What does the error Flag return  ? :

MsgBox($MB_SYSTEMMODAL, "", "Error = " & @error & @CRLF & "Result: " & $sFilePath)

What happens, when you use the registrykey from the Help ? :

Local $sFilePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")

 

Edited by Musashi
typo

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

leave comment blank. no results.

Since the key exists, I checked, including to not have a typo I copy the information.

 

image.thumb.png.f5b97cc2ddb159334611ee9979ae9b98.png

 

image.png.575d327336c2106be454533f47147a33.png

Posted
26 minutes ago, Musashi said:

What does the error Flag return  ? :

MsgBox($MB_SYSTEMMODAL, "", "Error = " & @error & @CRLF & "Result: " & $sFilePath)

Please use this MsgBox call. If RegRead does not return an error, then Error = 0 should appear there.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
29 minutes ago, Musashi said:

Please use this MsgBox call. If RegRead does not return an error, then Error = 0 should appear there.

Error = -1
Result:

  • Solution
Posted
16 minutes ago, ARPFre said:

Error = -1

Ok : -1 = unable to open requested value

Try :

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;#RequireAdmin

Local $sHKLM = @OSArch = "x64" ? "HKLM64" : "HKLM"
Local $sFilePath = RegRead($sHKLM & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI", "LastLoggedOnDisplayName")
MsgBox($MB_SYSTEMMODAL, "", "Error = " & @error & @CRLF & "Result: " & $sFilePath)

;RegTests
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData\1
;or
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
43 minutes ago, Musashi said:

Ok : -1 = unable to open requested value

Try :

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;#RequireAdmin

Local $sHKLM = @OSArch = "x64" ? "HKLM64" : "HKLM"
Local $sFilePath = RegRead($sHKLM & "\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI", "LastLoggedOnDisplayName")
MsgBox($MB_SYSTEMMODAL, "", "Error = " & @error & @CRLF & "Result: " & $sFilePath)

;RegTests
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData\1
;or
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI

 

Yea! It also works, I would like to learn how it works.

Two ways to skin a cat today! Thank you!

Posted
2 minutes ago, ARPFre said:

Can you please explain what it is for?

It forces your script to run in 64 bits (instead of 32 bits which is the default), thus reading differently the registry.  Just like @Musashi did with a more explicit approach.

Posted
6 minutes ago, Nine said:

It forces your script to run in 64 bits (instead of 32 bits which is the default), thus reading differently the registry.  Just like @Musashi did with a more explicit approach.

Thank you for the explanation.I understood perfectly.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...