Sagenur

Create script that handles registry variables

5 posts in this topic

#1 ·  Posted

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...

Unbenannt.png

Share this post


Link to post
Share on other sites



#2 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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