wheatberry Posted May 4, 2017 Share Posted May 4, 2017 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: #RequireAdmin #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) ExitLoop EndIf MsgBox($MB_SYSTEMMODAL, "Subkey #" & $i & ":", $sSubKey) $i = $i + 1 WEnd 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. Link to comment Share on other sites More sharing options...
Subz Posted May 4, 2017 Share Posted May 4, 2017 Assuming x64 System in which case use HKLM64 in place of HKEY_LOCAL_MACHINE spudw2k 1 Link to comment Share on other sites More sharing options...
wheatberry Posted May 4, 2017 Author Share Posted May 4, 2017 Yeah, it works. Many many thanks, Subz!! 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