Registry loop not reading any values

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
DataLife
Posts: 447
Joined: 29 Sep 2013, 19:52

Registry loop not reading any values

11 Jun 2018, 23:21

Why does this not read any key values?

Code: Select all

Loop, Reg, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles, KVR
{
    if A_LoopRegType = key
        value =
    else
    {
        RegRead, value
        if ErrorLevel
            value = *error*
    }
    MsgBox, 4, , %A_LoopRegName% = %value% (%A_LoopRegType%)`n`nContinue?
    IfMsgBox, NO, break
}
From the ahk help file works fine. I just replaced the keyname.

Code: Select all

Loop, Reg, HKEY_CURRENT_USER\Software\Microsoft\Windows, KVR
{
    if A_LoopRegType = key
        value =
    else
    {
        RegRead, value
        if ErrorLevel
            value = *error*
    }
    MsgBox, 4, , %A_LoopRegName% = %value% (%A_LoopRegType%)`n`nContinue?
    IfMsgBox, NO, break
}
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Registry loop not reading any values

12 Jun 2018, 02:51

Windows has different security settings for HKEY_LOCAL_MACHINE and for HKEY_CURRENT_USER and to prove it just run your script as admin and you will see it works, depending on what you need, there are ways to get it without the need to run as admin but not through the registry
User avatar
DataLife
Posts: 447
Joined: 29 Sep 2013, 19:52

Re: Registry loop not reading any values

12 Jun 2018, 07:52

AHKStudent wrote:Windows has different security settings for HKEY_LOCAL_MACHINE and for HKEY_CURRENT_USER and to prove it just run your script as admin and you will see it works, depending on what you need, there are ways to get it without the need to run as admin but not through the registry
I right clicked and chose "Run as administrator" and it did not work. I compiled it, then right clicked and chose "Run as administrator" and still it did nothing.

I am trying to retrieve the list of networks that windows has connected to in the past. I have 2 topics on this issue because....

At first I thought it was an issue retrieving the networks names and I was using this method at this post to retrieve the network names, so I posted here first.
https://autohotkey.com/boards/viewtopic.php?f=5&t=15316 (5th post from top)

And then I thought it was an issue with Ansi versus Unicode so I created a post....https://autohotkey.com/boards/viewtopic ... 35#p223235 (because I did not want to hijack the other users thread)

I thought if I could read from the registry and have the user take a screen shot of the results then I could see if his network names have unusual characters that Autohotkey is having an issue displaying.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Registry loop not reading any values

12 Jun 2018, 08:08

DataLife wrote:
AHKStudent wrote:Windows has different security settings for HKEY_LOCAL_MACHINE and for HKEY_CURRENT_USER and to prove it just run your script as admin and you will see it works, depending on what you need, there are ways to get it without the need to run as admin but not through the registry
I right clicked and chose "Run as administrator" and it did not work. I compiled it, then right clicked and chose "Run as administrator" and still it did nothing.

I am trying to retrieve the list of networks that windows has connected to in the past. I have 2 topics on this issue because....

At first I thought it was an issue retrieving the networks names and I was using this method at this post to retrieve the network names, so I posted here first.
https://autohotkey.com/boards/viewtopic.php?f=5&t=15316 (5th post from top)

And then I thought it was an issue with Ansi versus Unicode so I created a post....https://autohotkey.com/boards/viewtopic ... 35#p223235 (because I did not want to hijack the other users thread)

I thought if I could read from the registry and have the user take a screen shot of the results then I could see if his network names have unusual characters that Autohotkey is having an issue displaying.
did you test using netsh wlan export profile etc via cmd?
User avatar
DataLife
Posts: 447
Joined: 29 Sep 2013, 19:52

Re: Registry loop not reading any values

12 Jun 2018, 09:19

@AHKStudent
Thanks for the netsh suggestion. I will send a compiled script to my user in Sweden to see if these names are displayed properly.
This list only gets the Wlan connections. I have tried many command syntaxs but can not figure out how to display the wired network connections. I searched google and have not found the correct syntax.

Can you help me with this?
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Registry loop not reading any values

12 Jun 2018, 10:17

DataLife wrote:@AHKStudent
Thanks for the netsh suggestion. I will send a compiled script to my user in Sweden to see if these names are displayed properly.
This list only gets the Wlan connections. I have tried many command syntaxs but can not figure out how to display the wired network connections. I searched google and have not found the correct syntax.

Can you help me with this?
I do not know exactly what you need, try this wmi code save it as .vbs and run it, if it gives you the values you can convert to ahk

Code: Select all

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_NetworkLoginProfile",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_NetworkLoginProfile instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "AccountExpires: " & objItem.AccountExpires
    Wscript.Echo "AuthorizationFlags: " & objItem.AuthorizationFlags
    Wscript.Echo "BadPasswordCount: " & objItem.BadPasswordCount
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CodePage: " & objItem.CodePage
    Wscript.Echo "Comment: " & objItem.Comment
    Wscript.Echo "CountryCode: " & objItem.CountryCode
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "FullName: " & objItem.FullName
    Wscript.Echo "HomeDirectory: " & objItem.HomeDirectory
    Wscript.Echo "HomeDirectoryDrive: " & objItem.HomeDirectoryDrive
    Wscript.Echo "LastLogoff: " & objItem.LastLogoff
    Wscript.Echo "LastLogon: " & objItem.LastLogon
    Wscript.Echo "LogonHours: " & objItem.LogonHours
    Wscript.Echo "LogonServer: " & objItem.LogonServer
    Wscript.Echo "MaximumStorage: " & objItem.MaximumStorage
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NumberOfLogons: " & objItem.NumberOfLogons
    Wscript.Echo "Parameters: " & objItem.Parameters
    Wscript.Echo "PasswordAge: " & objItem.PasswordAge
    Wscript.Echo "PasswordExpires: " & objItem.PasswordExpires
    Wscript.Echo "PrimaryGroupId: " & objItem.PrimaryGroupId
    Wscript.Echo "Privileges: " & objItem.Privileges
    Wscript.Echo "Profile: " & objItem.Profile
    Wscript.Echo "ScriptPath: " & objItem.ScriptPath
    Wscript.Echo "SettingID: " & objItem.SettingID
    Wscript.Echo "UnitsPerWeek: " & objItem.UnitsPerWeek
    Wscript.Echo "UserComment: " & objItem.UserComment
    Wscript.Echo "UserId: " & objItem.UserId
    Wscript.Echo "UserType: " & objItem.UserType
    Wscript.Echo "Workstations: " & objItem.Workstations
Next
User avatar
DataLife
Posts: 447
Joined: 29 Sep 2013, 19:52

Re: Registry loop not reading any values

12 Jun 2018, 10:31

@AHKStudent
"I do not know exactly what you need"

I need a list of all wired network connections that the pc has ever been connected to. The code at the below 2 links do that but does not display properly. see this...https://autohotkey.com/boards/viewtopic.php?f=5&t=15316 (5th post from top)
AND this...
https://autohotkey.com/boards/viewtopic ... 35#p223235

Your netsh suggestion works great on wireless connections, I need wired connections.

I will try your wmi code.
thanks
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Registry loop not reading any values

12 Jun 2018, 10:52

I did not read the entire threads there, there are a lot of threads about wmi for non english

here is one example see the accepted reply, maybe its a start

https://stackoverflow.com/questions/595 ... sh-machine
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Registry loop not reading any values

12 Jun 2018, 10:57

DataLife wrote:Why does this not read any key values?
Did you try to read the registry on a 64-bit OS using AHK 32-bit?
SetRegView might help in this case (besides running the script as Admin).
User avatar
DataLife
Posts: 447
Joined: 29 Sep 2013, 19:52

Re: Registry loop not reading any values

12 Jun 2018, 13:56

just me wrote:
DataLife wrote:Why does this not read any key values?
Did you try to read the registry on a 64-bit OS using AHK 32-bit?
SetRegView might help in this case (besides running the script as Admin).
no go on 64 bit OS and ansi 32 bit.

SetRegView 64 and run as admin worked perfectly.

thanks very much
DataLife

P.S.
I am reading the registry specifically to see if displaying the networks retrieved from the registry is different then displaying them using the method below. This method below has unreadable characters for my user in Sweden. I have another thread asking for help on displaying the networks properly. I thought it was an ansi vs unicode issue.
https://autohotkey.com/boards/viewtopic ... 35#p223235

This method works fine with all my tests I.E Ansi & Unicode, but my user in Sweden is getting unreadable characters. Please see the link above for screen shots.

Code: Select all

for INetwork in ComObjCreate("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}").GetNetworks(3) 
 {
  	ptr := INetwork.GetName()
	NetworkName := StrGet( &ptr, StrLen( ptr ), "UTF-16" )
    NetworkList = %NetworkList%`n%NetworkName%
 } 
 
 MsgBox % networklist
 ExitApp
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Holarctic, mapcarter, robnicholson, Rohwedder and 335 guests