Jump to content

Recommended Posts

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

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

 

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.

  • Developers
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

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

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
×
×
  • Create New...