Jump to content

Blank Record Reading.


ARPFre
 Share

Go to solution Solved by Musashi,

Recommended Posts

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

 

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

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."

Link to comment
Share on other sites

  • Solution
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."

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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