ARPFre Posted February 21, 2022 Share Posted February 21, 2022 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 More sharing options...
Musashi Posted February 21, 2022 Share Posted February 21, 2022 (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 February 21, 2022 by Musashi typo "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 More sharing options...
ARPFre Posted February 21, 2022 Author Share Posted February 21, 2022 leave comment blank. no results. Since the key exists, I checked, including to not have a typo I copy the information. Link to comment Share on other sites More sharing options...
Musashi Posted February 21, 2022 Share Posted February 21, 2022 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. "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 More sharing options...
ARPFre Posted February 21, 2022 Author Share Posted February 21, 2022 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: Link to comment Share on other sites More sharing options...
Nine Posted February 21, 2022 Share Posted February 21, 2022 #AutoIt3Wrapper_UseX64=y solve your issue ARPFre 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Solution Musashi Posted February 21, 2022 Solution Share Posted February 21, 2022 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 ARPFre 1 "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 More sharing options...
ARPFre Posted February 21, 2022 Author Share Posted February 21, 2022 Thank you very much @Nine , yes the problem. Can you please explain what it is for? Link to comment Share on other sites More sharing options...
ARPFre Posted February 21, 2022 Author Share Posted February 21, 2022 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 More sharing options...
Nine Posted February 21, 2022 Share Posted February 21, 2022 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
ARPFre Posted February 21, 2022 Author Share Posted February 21, 2022 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now