Jump to content

RegWrite Issues


Recommended Posts

Hi all to the forum guru and expert I am trying to  automate this. in the registry  I have the network profile name network 2 and network   I want to  change their  CATEGORY  to Private .  Can someone lead me in the right direction.

Private is 1 and Public is 0

#RequireAdmin

Global $sHKLMRoot = @OSArch = "x64" ? "HKLM64" : "HKLM"


RegWrite($sHKLMRoot &"\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\NewNetworks" ,'/v NetworkList /t REG_MULTI_SZ /d 00000000 /f')

see  attached picture below

Much appreaciate

 

registry.JPG

Edited by antonioj84
Link to comment
Share on other sites

This topic over almost a year old and it doesn't look like you're really adding anything to it directly. It's prob best if you start your own topic.

 

You should follow the examples in this thread and read the regwrite function.

Link to comment
Share on other sites

As xCROv mentioned you should create a new thread and read the help file on RegWrite you will see your syntax is incorrect also you would need to use RegEnumKey, if you create a new post, I'll be happy to assist with your query.

 

Link to comment
Share on other sites

Thanks  Subz, and DanyFirex  Regnumkey was they key ingredient. If this can help someone else here is the code below 

#include <MsgBoxConstants.au3>
#RequireAdmin

Local Const $sHKLMRoot = @OSArch = "x64" ? "HKLM64" : "HKLM"

$iCategoryPrivate = 1
$iCategoryPublic = 0



Local $sSubKey =""
For $i =  1 To 2

$sSubKey = RegEnumKey($sHKLMRoot & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles", $i)
If @error Then ExitLoop




MsgBox($MB_SYSTEMMODAL, "SubKey #" & $i & " SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles: ", $sSubKey)


$sRegNetworkName = RegRead($sHKLMRoot & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\" & $sSubKey, "ProfileName")


 MsgBox($MB_SYSTEMMODAL, "Profile #" & $i & " SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles: ", $sRegNetworkName)


$Category = Int(RegRead($sHKLMRoot & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\" & $sSubKey, "Category"))


MsgBox($MB_SYSTEMMODAL, "Category #" & $i & " SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles: ", $Category)

;now you can write the key using regwrite to make category private or public
;~ RegWrite($sHKLMRoot & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles\" & $sSubKey, "Category", "REG_DWORD", $iCategoryPrivate)


Next

 

Link to comment
Share on other sites

I would normally write it this way, so you're not limited by multiple network connections

#RequireAdmin
Local $sHKLM = @OSArch = 'x64' ? 'HKLM64' : 'HKLM'
Local $sMainKey = $sHKLM & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles", $sSubkey, $i = 1
Local $iCategoryPrivate = 1, $iCategoryPublic = 0
While 1
    $sSubkey = RegEnumKey($sMainKey, $i)
        If @error Then ExitLoop
    If RegRead($sMainKey & "\" & $sSubkey, "ProfileName") = "Network" Then
;~      Uncomment line below to change category
;~      RegWrite($sMainKey & "\" & $sSubkey, "Category", "REG_DWORD", $iCategoryPrivate)
    ElseIf RegRead($sMainKey & "\" & $sSubkey, "ProfileName") = "Network 2" Then
;~      Uncomment line below to change category
;~      RegWrite($sMainKey & "\" & $sSubkey, "Category", "REG_DWORD", $iCategoryPrivate)
    EndIf
    $i += 1
WEnd
Link to comment
Share on other sites

  • Moderators

@antonioj84 you have been around long enough to know better than to hijack an old thread rather than creating your own. Please do so in the future.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

The old topic was a year old; I have split your intrusion into its own topic. What I am adding is that you need to create your own topics so someone from the Moderating team does not have to spend 20 minutes splitting them out.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

×
×
  • Create New...