Jump to content

Try to get network profile registries of Win7

Recommended Posts


Dear Sirs,

I will use VPN sometimes. The VPN client will connect to different VPN servers and leave a new network profile registries in my Win7 each time I use it. It's a bit scary when I see the network number keep increasing. However, I could manually remove those registries, and make the network number goes back to 0. That will make me feel comfortable. But it's tedious for trimming dozens of registries manually. An automatic way is really necessary for this job.

I am considering to write a AutoIt program to do it. My first step is trying to get the subkeys of those network profiles to see I could really handle it:

#include <MsgBoxConstants.au3>

Local $sSubKey = ""
Local $i = 1

While 1
    $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles", $i)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", @error)
    MsgBox($MB_SYSTEMMODAL, "Subkey #" & $i & ":", $sSubKey)
    $i = $i + 1

Too bad, I cannot get any registry at all, though I am pretty sure there are dozens of them there. The return error is -1: unable to retrieve requested subkey (key instance out of range)

I don't write AutoIt script for a long time. There might be something wrong in my code.

Any help will be appreciated.

Share this post

Link to post
Share on other sites

Assuming x64 System in which case use HKLM64 in place of HKEY_LOCAL_MACHINE

  • Like 1

Share this post

Link to post
Share on other sites

Yeah, it works. Many many thanks, Subz!!

Share this post

Link to post
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