Sagenur Posted May 27, 2017 Share Posted May 27, 2017 How to create a script that changes the location (Category) of all network profiles from "public" (0) to "private" (1) and handles variables like the random generated folder names for each network? Also the amount of folders will increase with time as the device will connect to more networks... Link to comment Share on other sites More sharing options...
Developers Jos Posted May 27, 2017 Developers Share Posted May 27, 2017 Just look at RegEnumKey() in the helpfile, which should allow you to iterate through all available profiles and check for the Category value for each. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Subz Posted May 27, 2017 Share Posted May 27, 2017 Was bored so thought I'd write an example: #RequireAdmin #include <Array.au3> Global $sKeyProfiles32 = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" Global $sKeyProfiles64 = "HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" Global $aKeyProfiles[0][4] _ArrayAdd($aKeyProfiles, "Registry Key|Profile Guid|Category Value|Category Type") RegEnumProfiles($sKeyProfiles32) RegEnumProfiles($sKeyProfiles64) _ArrayDisplay($aKeyProfiles) Func RegEnumProfiles($sKeyProfiles = $sKeyProfiles32) Local $sKeyProfile, $iValCategory, $sValCategory, $i = 1 While 1 $sKeyProfile = RegEnumKey($sKeyProfiles, $i) If @error Then ExitLoop $iValCategory = RegRead($sKeyProfiles & "\" & $sKeyProfile, "Category") Switch $iValCategory Case 0 $sValCategory = "Public" Case 1 $sValCategory = "Home" Case 2 $sValCategory = "Work" EndSwitch _ArrayAdd($aKeyProfiles, $sKeyProfiles & "|" & $sKeyProfile & "|" & $iValCategory & "|" & $sValCategory) $i += 1 WEnd EndFunc Link to comment Share on other sites More sharing options...
Sagenur Posted May 28, 2017 Author Share Posted May 28, 2017 20 hours ago, Subz said: Was bored so thought I'd write an example: #RequireAdmin #include <Array.au3> Global $sKeyProfiles32 = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" Global $sKeyProfiles64 = "HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" Global $aKeyProfiles[0][4] _ArrayAdd($aKeyProfiles, "Registry Key|Profile Guid|Category Value|Category Type") RegEnumProfiles($sKeyProfiles32) RegEnumProfiles($sKeyProfiles64) _ArrayDisplay($aKeyProfiles) Func RegEnumProfiles($sKeyProfiles = $sKeyProfiles32) Local $sKeyProfile, $iValCategory, $sValCategory, $i = 1 While 1 $sKeyProfile = RegEnumKey($sKeyProfiles, $i) If @error Then ExitLoop $iValCategory = RegRead($sKeyProfiles & "\" & $sKeyProfile, "Category") Switch $iValCategory Case 0 $sValCategory = "Public" Case 1 $sValCategory = "Home" Case 2 $sValCategory = "Work" EndSwitch _ArrayAdd($aKeyProfiles, $sKeyProfiles & "|" & $sKeyProfile & "|" & $iValCategory & "|" & $sValCategory) $i += 1 WEnd EndFunc Thank you very much! It recognizing the proper registry keys but it doesn't change anything... I did run it with Admin rights but I am completely new to AutoIt, so maybe I am doing something wrong. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 28, 2017 Developers Share Posted May 28, 2017 There is no RegWrite() in there so nothing will change. Just go through the script and try understanding what it is doing so you also understand where that RegWrite() should be. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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