Sign in to follow this  
Followers 0
nitekram

Can someone link me to Network_Profiles.au3

2 posts in this topic

#1 ·  Posted (edited)

I found this script once! Cannot find it again. Please help?

Thanks

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Allow_Decompile=n
#AutoIt3Wrapper_Res_Comment=Network_Profiles
#AutoIt3Wrapper_Res_Description=Network_Profiles
#AutoIt3Wrapper_Res_Fileversion=3.2.5.1
#AutoIt3Wrapper_Res_LegalCopyright=PSandu.ro
#AutoIt3Wrapper_Res_Language=1048
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt('TrayMenuMode', 1)
Opt('GUIOnEventMode', 1)
Opt('MustDeclareVars', 1)
Opt('GUICloseOnESC', 0)
Opt("WinTitleMatchMode", 2)
#Include <GuiConstants.au3>
#Include <GuiTreeView.au3>
#Include <Constants.au3>
#Include <GuiCombo.au3>
#Include <Misc.au3>
#Include <GuiIPAddress.au3>
#Include <GuiListView.au3>
_Singleton('ewrocnvdfm_welvknerefi9#$%$#RE')
ProcessSetPriority(@AutoItPID, 3)
If @OSTYPE <> 'WIN32_NT'  Then
    MsgBox(262144 + 16, 'Sorry!', 'Only Win_2000, Win_XP or Win_2003')
    Exit 0
EndIf
FileCreateShortcut(@ScriptFullPath, @AppDataDir & '\Microsoft\Internet Explorer\Quick Launch\Network Profiles.lnk', @ScriptDir, '', 'Network Profiles', @ScriptFullPath, '', '0')
RegDelete('HKEY_CURRENT_USER\Software\NetworkProfiles')
TraySetToolTip('Network Profiles (' & FileGetVersion(@AutoItExe) & ')')
If FileExists(@ScriptDir & '\Network_Profiles.sav') Then
    FileCopy(@ScriptDir & '\Network_Profiles.sav', @TempDir & '\Network_Profiles.reg', 1)
    _RunDOS('reg import ' & @TempDir & '\Network_Profiles.reg')
    FileDelete(@TempDir & '\Network_Profiles.reg')
EndIf
If FileExists(@WindowsDir & '\system32\uxtheme.dll') Then DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
Global $objwmiservice = ObjGet('winmgmts:\\.\root\CIMV2'), $font = 'MS Sans Serif', $newdns2, $newdhcpwins, $newmanwins
Global Const $wm_timer = 0x0113
Global $maingui, $hidefocus, $treeview1, $maintreeview1, $treeview2, $newprofilebutton, $treeviewsel = '', $newmandns, $newdns1, $caption = ''
Global $newgui, $netadapterlist, $newprofilename, $adapterchoose, $newdhcpip, $newmanip, $newip, $newsubnet, $newgateway, $newdhcpdns, $list_available_conn
Global $newwins, $proxycheck, $proxy, $port, $maccheck, $mac, $finishnew, $enabledgui, $deleteprofilebutton, $treeview1_profile, $applyprofilebutton, $replaceprofilebutton
Global $value_ = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings")
Global $byte_ = Dec(StringMid($value_, 18, 1)), $guianotherinterface, $anotherinterfbutton
If $byte_ = BitAND($byte_, 7) Then $byte_ = BitOR($byte_, 8)
$byte_ = Hex($byte_, 1)
$value_ = StringMid($value_, 1, 17) & $byte_ & StringMid($value_, 19, StringLen($value_) - 18)
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections", "DefaultConnectionSettings", "REG_BINARY", $value_)
Dim $mac[6]
$maingui = GUICreate('Network profiles', 600, 330, -1, -1, $ws_sysmenu, $ws_ex_toolwindow + $ws_ex_topmost)
GUISetFont(10, 400, 0, $font, $maingui)
GUISetOnEvent($gui_event_close, 'Finish')
$hidefocus = GUICtrlCreateButton('', -99, -99, -1, -1)
$treeview1 = GUICtrlCreateTreeView(1, 1, 190, 260, $tvs_disabledragdrop, $ws_ex_clientedge)
GUICtrlSetFont($treeview1, 11, 400, 0, $font)
$maintreeview1 = GUICtrlCreateTreeViewItem("Profile's Name:", $treeview1)
_GUICtrlTreeViewSetState($treeview1, $maintreeview1, $tvis_bold)
For $profileidx = 1 To 500
    Local $profilesaved = RegEnumKey('HKEY_CURRENT_USER\Software\NetworkProfiles', $profileidx)
    If @error <> 0 Then ExitLoop
    $treeview1_profile = GUICtrlCreateTreeViewItem($profilesaved, $maintreeview1)
Next
$treeview2 = GUICtrlCreateTreeView(191, 1, 402, 260, $tvs_disabledragdrop, $ws_ex_clientedge)
GUICtrlSetFont($treeview2, 11, 400, 0, $font)
GUICtrlCreateTreeViewItem('Select a profile', $treeview2)
$newprofilebutton = GUICtrlCreateButton('New', 39, 270, 100, 25, $bs_flat)
GUICtrlSetFont($newprofilebutton, 11, 400, 0, $font)
GUICtrlSetOnEvent($newprofilebutton, 'NewProfile')
$deleteprofilebutton = GUICtrlCreateButton('Delete', 178, 270, 100, 25, $bs_flat)
GUICtrlSetFont($deleteprofilebutton, 11, 400, 0, $font)
GUICtrlSetOnEvent($deleteprofilebutton, 'DeleteProfile')
$applyprofilebutton = GUICtrlCreateButton('Apply', 456, 270, 100, 25, $bs_flat)
GUICtrlSetFont($applyprofilebutton, 11, 400, 0, $font)
GUICtrlSetOnEvent($applyprofilebutton, 'ApplyProfile')
$replaceprofilebutton = GUICtrlCreateButton('Replace', 317, 270, 100, 25, $bs_flat)
GUICtrlSetFont($replaceprofilebutton, 11, 400, 0, $font)
GUICtrlSetOnEvent($replaceprofilebutton, 'ReplaceNetConnIDInProfile')
_GUICtrlTreeViewSort($treeview1)
_GUICtrlTreeViewExpand($treeview1)
_GUICtrlTreeViewExpand($treeview2)
DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
GUISetState()
GUIRegisterMsg($wm_timer, "_TimerFunc")
DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
While 1
    Sleep(10)
    If $treeviewsel <> _GUICtrlTreeViewGetText($treeview1, GUICtrlRead($treeview1)) Then
        $treeviewsel = _GUICtrlTreeViewGetText($treeview1, GUICtrlRead($treeview1))
        TreeViewDetail($treeviewsel)
    EndIf
WEnd
Func TreeViewDetail($detail)
    Local $regreadtmp
    _GUICtrlTreeViewDeleteAllItems($treeview2)
    Select
        Case $detail <> "Profile's Name:"
            Local $maintreeview2 = GUICtrlCreateTreeViewItem('Profile - ' & $detail, $treeview2)
            _GUICtrlTreeViewSetState($treeview2, $maintreeview2, $tvis_bold)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'NetConnectionId')
            Local $contreeview2 = GUICtrlCreateTreeViewItem('NetConnectionId: ' & $regreadtmp, $maintreeview2)
            _GUICtrlTreeViewSetState($treeview2, $contreeview2, $tvis_bold)
            Local $ipsettingsitem = GUICtrlCreateTreeViewItem('# IP Settings - ' & RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'IP Settings'), $contreeview2)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'IP')
            GUICtrlCreateTreeViewItem('   ' & ChrW(8226) & ' IP: ' & $regreadtmp, $ipsettingsitem)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'Subnet')
            GUICtrlCreateTreeViewItem('   ' & ChrW(8226) & ' Subnet: ' & $regreadtmp, $ipsettingsitem)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'Gateway')
            GUICtrlCreateTreeViewItem('   ' & ChrW(8226) & ' Gateway: ' & $regreadtmp, $ipsettingsitem)
            Local $dnssettingsitem = GUICtrlCreateTreeViewItem('# DNS Settings - ' & RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'DNS Settings'), $contreeview2)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'DNS_1')
            GUICtrlCreateTreeViewItem('   ' & ChrW(8226) & ' Preffered DNS: ' & $regreadtmp, $dnssettingsitem)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'DNS_2')
            GUICtrlCreateTreeViewItem('   ' & ChrW(8226) & ' Alternate DNS: ' & $regreadtmp, $dnssettingsitem)
            Local $winssettingsitem = GUICtrlCreateTreeViewItem('# WINS Settings - ' & RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'WINS Settings'), $contreeview2)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'WINS')
            GUICtrlCreateTreeViewItem('   ' & ChrW(8226) & ' Preffered WINS: ' & $regreadtmp, $winssettingsitem)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'ProxyServer')
            GUICtrlCreateTreeViewItem('# Proxy Server: ' & $regreadtmp, $contreeview2)
            $regreadtmp = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $detail, 'Physical Address')
            Local $mactmp = ''
            For $regtmp = 1 To StringLen($regreadtmp) Step 2
                $mactmp &= StringMid($regreadtmp, $regtmp, 2) & '-'
            Next
            If StringRight($mactmp, 1) = '-'  Then $mactmp = StringTrimRight($mactmp, 1)
            GUICtrlCreateTreeViewItem('# Physical Address: ' & $mactmp, $contreeview2)
        Case Else
            GUICtrlCreateTreeViewItem('Select a profile', $treeview2)
    EndSelect
    _GUICtrlTreeViewExpand($treeview2)
EndFunc   ;==>TreeViewDetail
Func GetNetworkAdapters()
    Local $getmac = Run('getmac /fo list /v', '', @SW_HIDE, $stdout_child), $resultgetmac = ''
    Do
        $resultgetmac &= StdoutRead($getmac)
    Until @error
    While StringInStr($resultgetmac, '  ') > 0
        $resultgetmac = StringReplace($resultgetmac, '  ', ' ')
    WEnd
    While StringInStr($resultgetmac, ': ') > 0
        $resultgetmac = StringReplace($resultgetmac, ': ', ':')
    WEnd
    $resultgetmac = StringReplace($resultgetmac, 'Connection Name:', '')
    $resultgetmac = StringReplace($resultgetmac, 'Network Adapter:', '')
    $resultgetmac = StringReplace($resultgetmac, 'Physical Address:', '')
    $resultgetmac = StringReplace($resultgetmac, 'Transport Name:', '')
    $resultgetmac = StringSplit(StringReplace(StringReplace(StringTrimRight(StringTrimLeft($resultgetmac, 2), 2), @CRLF & @CRLF, @CRLF), @CRLF & ' ', ' '), @CRLF, 1)
    Local $returngetmac = ''
    For $getmacidx = 1 To $resultgetmac[0] Step 4
        If $resultgetmac[$getmacidx + 3] <> 'Disconnected'  Then $returngetmac &= $resultgetmac[$getmacidx] & '|'
    Next
    If StringRight($returngetmac, 1) = '|'  Then $returngetmac = StringTrimRight($returngetmac, 1)
    Return StringSplit($returngetmac, '|', 1)
EndFunc   ;==>GetNetworkAdapters
Func Finish()
    TrayTip('', 'Closing...', 1)
    GUISetState(@SW_HIDE)
    _RunDOS('reg export HKEY_CURRENT_USER\Software\NetworkProfiles ' & @TempDir & '\Network_Profiles.reg')
    FileDelete(@ScriptDir & '\Network_Profiles.sav')
    FileCopy(@TempDir & '\Network_Profiles.reg', @ScriptDir & '\Network_Profiles.sav', 1)
    FileDelete(@TempDir & '\Network_Profiles.reg')
    RegDelete('HKEY_CURRENT_USER\Software\NetworkProfiles')
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $maingui, "int_ptr", 50)
    Exit 0
EndFunc   ;==>Finish
Func _TimerFunc()
    GUICtrlSetState($hidefocus, $gui_focus)
    _GUICtrlTreeViewExpand($treeview1)
    _GUICtrlTreeViewExpand($treeview2)
EndFunc   ;==>_TimerFunc
Func DeleteNew()
    GUIDelete($newgui)
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
    WinSetState('Network profiles', '', @SW_ENABLE)
    WinActivate('Network profiles')
    DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndFunc   ;==>DeleteNew
Func NewProfile()
    $enabledgui = False
    DllCall("user32.dll", "int", "KillTimer", "hwnd", $maingui, "int_ptr", 50)
    DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    GUICtrlSetState($hidefocus, $gui_focus)
    WinSetState('Network profiles', '', @SW_DISABLE)
    $newgui = GUICreate('New', 250, 623, -1, -1, $ws_sysmenu, $ws_ex_toolwindow + $ws_ex_topmost, $maingui)
    GUISetOnEvent($gui_event_close, 'DeleteNew')
    GUICtrlCreateLabel('Profile Name', 10, 5, 83, 19)
    GUICtrlSetFont(-1, 11, 400, 0, $font)
    $newprofilename = GUICtrlCreateInput('', 10, 23, 224, 20, $es_center + $es_oemconvert)
    GUICtrlSetFont($newprofilename, 11, 400, 0, $font)
    GUICtrlCreateLabel('NetConnectionID', 10, 50, 105, 19)
    GUICtrlSetFont(-1, 11, 400, 0, $font)
    $adapterchoose = GUICtrlCreateCombo('updating...please wait', 10, 68, 224, 20, $lbs_standard + $cbs_sort)
    GUICtrlSetFont($adapterchoose, 9.8, 100, 0, $font)
    GUICtrlCreateGroup('IP Settings', 10, 95, 224, 133)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newdhcpip = GUICtrlCreateRadio('Assigned by DHCP', 20, 112, 150, 20)
    GUICtrlSetFont($newdhcpip, 11, 100, 0, $font)
    GUICtrlSetState($newdhcpip, $gui_checked)
    GUICtrlSetOnEvent($newdhcpip, 'DhcpIp')
    $newmanip = GUICtrlCreateRadio('Manually Configured', 20, 132, 150)
    GUICtrlSetFont($newmanip, 11, 100, 0, $font)
    GUICtrlSetOnEvent($newmanip, 'ManuallyIP')
    GUICtrlCreateLabel('IP', 23, 160, 30, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newip = _GUICtrlIpAddressCreate($newgui, 97, 158, 123, 20)
    _GUICtrlIpAddressSetFont($newip, $font, 11, 40)
    GUICtrlCreateLabel('Subnet', 23, 180, 50, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newsubnet = _GUICtrlIpAddressCreate($newgui, 97, 178, 123, 20)
    _GUICtrlIpAddressSetFont($newsubnet, $font, 11, 40)
    GUICtrlCreateLabel('Gateway', 23, 200, 60, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newgateway = _GUICtrlIpAddressCreate($newgui, 97, 198, 123, 20)
    _GUICtrlIpAddressSetFont($newgateway, $font, 11, 40)
    GUICtrlCreateGroup('', -999, 999, -1, -1)
    GUICtrlCreateGroup('DNS Settings', 10, 235, 224, 116)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newdhcpdns = GUICtrlCreateRadio('Assigned by DHCP', 20, 252, 150, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetState($newdhcpdns, $gui_checked)
    GUICtrlSetOnEvent($newdhcpdns, 'DhcpDNS')
    $newmandns = GUICtrlCreateRadio('Manually Configured', 20, 272, 150)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetOnEvent($newmandns, 'ManDNS')
    GUICtrlCreateLabel('Preferred', 23, 300, 60, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newdns1 = _GUICtrlIpAddressCreate($newgui, 97, 298, 123, 20)
    _GUICtrlIpAddressSetFont($newdns1, $font, 11, 40)
    GUICtrlCreateLabel('Alternate', 23, 320, 60, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newdns2 = _GUICtrlIpAddressCreate($newgui, 97, 318, 123, 20)
    _GUICtrlIpAddressSetFont($newdns2, $font, 11, 40)
    GUICtrlCreateGroup('', -999, 999, -1, -1)
    GUICtrlCreateGroup('WINS Settings', 10, 355, 224, 95)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newdhcpwins = GUICtrlCreateRadio('Assigned by DHCP', 20, 373, 150, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetState($newdhcpwins, $gui_checked)
    GUICtrlSetOnEvent($newdhcpwins, 'DhcpWins')
    $newmanwins = GUICtrlCreateRadio('Manually Configured', 20, 393, 150, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetOnEvent($newmanwins, 'ManWins')
    GUICtrlCreateLabel('WINS', 23, 422, 40, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $newwins = _GUICtrlIpAddressCreate($newgui, 97, 420, 123, 20)
    _GUICtrlIpAddressSetFont($newwins, $font, 11, 40)
    GUICtrlCreateGroup('', -999, 999, -1, -1)
    $proxycheck = GUICtrlCreateCheckbox('Proxy Server', 23, 457, 150, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetOnEvent($proxycheck, 'ProxyCheck')
    $proxy = GUICtrlCreateInput('', 10, 480, 165, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlCreateLabel(':', 175, 478, 9, 20, $ss_center)
    GUICtrlSetFont(-1, 12, 100, 0, $font)
    $port = GUICtrlCreateInput('', 184, 480, 51, 20, $es_number + $es_center)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetState($proxy, $gui_disable)
    GUICtrlSetState($port, $gui_disable)
    Local $proxyitems = $objwmiservice.ExecQuery ('SELECT * FROM NetDiagnostics', 'WQL', 0x30)
    If IsObj($proxyitems) Then
        For $objitem In $proxyitems
            Select
                Case Not (Not ($objitem.bieproxy))
                    GUICtrlSetState($proxycheck, $gui_checked)
                Case Else
                    GUICtrlSetState($proxycheck, $gui_unchecked)
            EndSelect
            If StringLen($objitem.ieproxy) = 0 Then GUICtrlSetData($proxy, '')
            If StringLen($objitem.ieproxy) <> 0 Then GUICtrlSetData($proxy, $objitem.ieproxy)
            If StringLen($objitem.ieproxyport) = 0 Then GUICtrlSetData($port, '')
            If StringLen($objitem.ieproxyport) <> 0 Then GUICtrlSetData($port, $objitem.ieproxyport)
        Next
    EndIf
    $maccheck = GUICtrlCreateCheckbox('Physical Address', 23, 507, 150, 20)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetOnEvent($maccheck, 'MacCheck')
    Local $macx = 10
    $mac[0] = GUICtrlCreateInput('', $macx, 453 + 78, 29, -1, $es_center + $es_uppercase)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetLimit(-1, 2)
    GUICtrlCreateLabel('-', $macx + 29, 452 + 78, 10, 20, $ss_centerimage + $ss_center)
    GUICtrlSetFont(-1, 12, 100, 0, $font)
    $mac[1] = GUICtrlCreateInput('', $macx + 39, 453 + 78, 29, -1, $es_center + $es_uppercase)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetLimit(-1, 2)
    GUICtrlCreateLabel('-', $macx + 68, 452 + 78, 10, 20, $ss_centerimage + $ss_center)
    GUICtrlSetFont(-1, 12, 100, 0, $font)
    $mac[2] = GUICtrlCreateInput('', $macx + 78, 453 + 78, 29, -1, $es_center + $es_uppercase)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetLimit(-1, 2)
    GUICtrlCreateLabel('-', $macx + 107, 452 + 78, 10, 20, $ss_centerimage + $ss_center)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $mac[3] = GUICtrlCreateInput('', $macx + 117, 453 + 78, 29, -1, $es_center + $es_uppercase)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetLimit(-1, 2)
    GUICtrlCreateLabel('-', $macx + 146, 452 + 78, 10, 20, $ss_centerimage + $ss_center)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $mac[4] = GUICtrlCreateInput('', $macx + 156, 453 + 78, 29, -1, $es_center + $es_uppercase)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetLimit(-1, 2)
    GUICtrlCreateLabel('-', $macx + 185, 452 + 78, 10, 20, $ss_centerimage + $ss_center)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    $mac[5] = GUICtrlCreateInput('', $macx + 195, 453 + 78, 29, -1, $es_center + $es_uppercase)
    GUICtrlSetFont(-1, 11, 100, 0, $font)
    GUICtrlSetLimit(-1, 2)
    For $macidx = 0 To 5
        GUICtrlSetState($mac[$macidx], $gui_disable)
    Next
    $finishnew = GUICtrlCreateButton('OK', 87, 565, 70)
    GUICtrlSetOnEvent($finishnew, 'Finish_New')
    For $editdisable = 2 To 25
        ControlDisable('New', '', 'Edit' & $editdisable)
    Next
    ChangeControlStatus('gui_disable')
    GUISetState()
    $netadapterlist = GetNetworkAdapters()
    _GUICtrlComboResetContent($adapterchoose)
    For $newidx = 1 To $netadapterlist[0]
        GUICtrlSetData($adapterchoose, $netadapterlist[$newidx])
    Next
    GUICtrlSetOnEvent($adapterchoose, 'ChooseConnection')
EndFunc   ;==>NewProfile
Func ChooseConnection()
    If Not $enabledgui Then
        ChangeControlStatus('gui_enable')
        $enabledgui = True
    EndIf
    GUICtrlSetState($maccheck, $gui_unchecked)
    _GUICtrlIpAddressClear($newip)
    _GUICtrlIpAddressClear($newsubnet)
    _GUICtrlIpAddressClear($newgateway)
    _GUICtrlIpAddressClear($newdns1)
    _GUICtrlIpAddressClear($newdns2)
    _GUICtrlIpAddressClear($newwins)
    For $macidx = 0 To 5
        GUICtrlSetData($mac[$macidx], '')
    Next
    Local $connectionchoosed = GUICtrlRead($adapterchoose)
    BlockInput(1)
    ToolTip('updating...')
    If NetAdapterGetStatus($connectionchoosed) = 'Enabled'  Then
        GetInterfaceIP($connectionchoosed)
    EndIf
    ToolTip('')
    BlockInput(0)
EndFunc   ;==>ChooseConnection
Func NetAdapterChangeStatus($netconnectionidstatus__, $netstatus)
    Local $shellapp = ObjCreate('shell.application')
    Local $ocontrolpanel = $shellapp.Namespace (3)
    For $folderitem In $ocontrolpanel.items
        If $folderitem.name = 'Network Connections'  Then
            For $folderitem In $folderitem.getfolder.items
                If StringLower($folderitem.name) = StringLower($netconnectionidstatus__) Then
                    For $verb In $folderitem.verbs
                        If StringLower(StringReplace($verb.name, '&', '')) = StringLower($netstatus) Then $verb.doit
                        If $netstatus = 'Enable'  Then
                            Do
                                Sleep(33)
                            Until NetAdapterGetStatus($netconnectionidstatus__) = 'Enabled'
                            Return 'Done'
                        EndIf
                        If $netstatus = 'Disable'  Then
                            Do
                                Sleep(33)
                            Until NetAdapterGetStatus($netconnectionidstatus__) = 'Disabled'
                            Return 'Done'
                        EndIf
                    Next
                EndIf
            Next
        EndIf
    Next
EndFunc   ;==>NetAdapterChangeStatus
Func NetAdapterGetStatus($netconnectionidgetstatus_)
    Local $shellapp = ObjCreate('shell.application')
    Local $ocontrolpanel = $shellapp.Namespace (3)
    For $folderitem In $ocontrolpanel.items
        If $folderitem.name = 'Network Connections'  Then
            For $folderitem In $folderitem.getfolder.items
                If StringLower($folderitem.name) = StringLower($netconnectionidgetstatus_) Then
                    For $verb In $folderitem.verbs
                        If StringLower(StringReplace($verb.name, '&', '')) = 'enable'  Then Return 'Disabled'
                        If StringLower(StringReplace($verb.name, '&', '')) = 'disable'  Then Return 'Enabled'
                    Next
                EndIf
            Next
        EndIf
    Next
EndFunc   ;==>NetAdapterGetStatus
Func ChangeControlStatus($controlstatus)
    GUICtrlSetState($newdhcpip, Eval($controlstatus))
    GUICtrlSetState($newmanip, Eval($controlstatus))
    GUICtrlSetState($newdhcpdns, Eval($controlstatus))
    GUICtrlSetState($newmandns, Eval($controlstatus))
    GUICtrlSetState($newdhcpwins, Eval($controlstatus))
    GUICtrlSetState($newmanwins, Eval($controlstatus))
    GUICtrlSetState($proxycheck, Eval($controlstatus))
    GUICtrlSetState($maccheck, Eval($controlstatus))
    GUICtrlSetState($finishnew, Eval($controlstatus))
    If Eval($controlstatus) = $gui_disable Then
        GUICtrlSetState($proxy, $gui_disable)
        GUICtrlSetState($port, $gui_disable)
    EndIf
    If Eval($controlstatus) = $gui_enable And GUICtrlRead($proxycheck) = 1 Then
        GUICtrlSetState($proxy, $gui_enable)
        GUICtrlSetState($port, $gui_enable)
    EndIf
EndFunc   ;==>ChangeControlStatus
Func ManuallyIP()
    GUICtrlSetState($newdhcpdns, $gui_disable)
    GUICtrlSetState($newmandns, $gui_checked)
    GUICtrlSetState($newdhcpwins, $gui_disable)
    GUICtrlSetState($newmanwins, $gui_checked)
    For $editdisable = 2 To 25
        ControlEnable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>ManuallyIP
Func DhcpIP()
    GUICtrlSetState($newdhcpdns, $gui_enable)
    GUICtrlSetState($newdhcpwins, $gui_enable)
    For $editdisable = 2 To 13
        ControlDisable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>DhcpIP
Func DhcpDNS()
    For $editdisable = 14 To 21
        ControlDisable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>DhcpDNS
Func ManDNS()
    For $editdisable = 14 To 21
        ControlEnable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>ManDNS
Func DhcpWins()
    For $editdisable = 22 To 25
        ControlDisable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>DhcpWins
Func ManWins()
    For $editdisable = 22 To 25
        ControlEnable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>ManWins
Func ProxyCheck()
    Select
        Case GUICtrlRead($proxycheck) = 4
            GUICtrlSetState($proxy, $gui_disable)
            GUICtrlSetState($port, $gui_disable)
        Case GUICtrlRead($proxycheck) = 1
            GUICtrlSetState($proxy, $gui_enable)
            GUICtrlSetState($port, $gui_enable)
    EndSelect
EndFunc   ;==>ProxyCheck
Func ResetToDhcp()
    GUICtrlSetState($newdhcpip, $gui_checked)
    GUICtrlSetState($newdhcpdns, $gui_checked)
    GUICtrlSetState($newdhcpwins, $gui_checked)
    GUICtrlSetState($newdhcpdns, $gui_enable)
    GUICtrlSetState($newdhcpwins, $gui_enable)
    For $editdisable = 2 To 25
        ControlDisable('New', '', 'Edit' & $editdisable)
    Next
EndFunc   ;==>ResetToDhcp
Func MacCheck()
    Select
        Case GUICtrlRead($maccheck) = 4
            For $temp = 0 To 5
                GUICtrlSetState($mac[$temp], $gui_disable)
            Next
        Case GUICtrlRead($maccheck) = 1
            For $temp = 0 To 5
                GUICtrlSetState($mac[$temp], $gui_enable)
            Next
    EndSelect
EndFunc   ;==>MacCheck
Func GetInterfaceIP($interface)
    Local $resultinterfaceip = '', $interface_ = $interface
    Local $conitems = $objwmiservice.ExecQuery ("SELECT * FROM Win32_NetworkAdapter Where NetConnectionId='" & $interface & "'", 'WQL', 0x30)
    For $objitem In $conitems
        $caption = StringLeft(StringTrimLeft(String($objitem.caption), 5), 4)
        ExitLoop
    Next
    Select
        Case RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\' & $caption, 'NetworkAddress') <> ''
            GUICtrlSetState($maccheck, $gui_checked)
            For $macidx = 0 To 5
                GUICtrlSetState($mac[$macidx], $gui_enable)
            Next
        Case Else
            GUICtrlSetState($maccheck, $gui_unchecked)
            For $macidx = 0 To 5
                GUICtrlSetState($mac[$macidx], $gui_disable)
            Next
    EndSelect
    Local $interfacepid = Run('ipconfig /all', '', @SW_HIDE, $stdout_child)
    Do
        $resultinterfaceip &= StdoutRead($interfacepid)
    Until @error
    $resultinterfaceip = StringReplace(StringReplace($resultinterfaceip, @CR, ''), @LF, @CRLF)
    Do
        $resultinterfaceip = StringReplace($resultinterfaceip, '  ', ' ')
    Until $resultinterfaceip = StringReplace($resultinterfaceip, '  ', ' ')
    Do
        $resultinterfaceip = StringReplace($resultinterfaceip, ' : ', ':')
    Until $resultinterfaceip = StringReplace($resultinterfaceip, ' : ', ':')
    Do
        $resultinterfaceip = StringReplace($resultinterfaceip, ' .', '')
    Until $resultinterfaceip = StringReplace($resultinterfaceip, ' .', '')
    Do
        $resultinterfaceip = StringReplace($resultinterfaceip, '.:', ':')
    Until $resultinterfaceip = StringReplace($resultinterfaceip, '.:', ':')
    Do
        $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & @CRLF, @CRLF)
    Until $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & @CRLF, '')
    Do
        $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & ' ', @CRLF)
    Until $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & ' ', @CRLF)
    If StringRight($resultinterfaceip, 2) = @CRLF Then $resultinterfaceip = StringTrimRight($resultinterfaceip, 2)
    Local $splitinterface = StringSplit($resultinterfaceip, 'Ethernet adapter ', 1)
    For $interfaceidx = 1 To $splitinterface[0]
        If $splitinterface[$interfaceidx] <> StringReplace($splitinterface[$interfaceidx], $interface & ':', '') Then
            $interface = StringTrimLeft(StringReplace($splitinterface[$interfaceidx], $interface & ':', ''), 2)
            ExitLoop
        EndIf
    Next
    If StringReplace($interface, 'Media disconnected', '') <> $interface Then
        ResetToDhcp()
        $resultinterfaceip = StringSplit($interface, 'Physical Address:', 1)
        Local $physical_address = StringSplit(StringLeft($resultinterfaceip[2], 17), '-', 1)
        For $macidx = 0 To 5
            GUICtrlSetData($mac[$macidx], $physical_address[$macidx + 1])
        Next
    EndIf
    If StringReplace($interface, 'Media disconnected', '') = $interface Then
        Local $resultinterfaceiptemp = StringSplit($interface, @CRLF, 1)
        For $resultinterfaceipidx = 1 To $resultinterfaceiptemp[0]
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'IP Address:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx] Then
                _GUICtrlIpAddressSet($newip, StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'IP Address:', ''))
            EndIf
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Subnet Mask:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx] Then
                _GUICtrlIpAddressSet($newsubnet, StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Subnet Mask:', ''))
            EndIf
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Default Gateway:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx] Then
                _GUICtrlIpAddressSet($newgateway, StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Default Gateway:', ''))
            EndIf
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'DNS Servers:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx] Then
                _GUICtrlIpAddressSet($newdns1, StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'DNS Servers:', ''))
            EndIf
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], ':', '') = $resultinterfaceiptemp[$resultinterfaceipidx] And StringReplace($resultinterfaceiptemp[$resultinterfaceipidx - 1], 'DNS Servers:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx - 1] Then
                _GUICtrlIpAddressSet($newdns2, $resultinterfaceiptemp[$resultinterfaceipidx])
            EndIf
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Primary WINS Server:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx] Then
                _GUICtrlIpAddressSet($newwins, StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Primary WINS Server:', ''))
            EndIf
            If StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Physical Address:', '') <> $resultinterfaceiptemp[$resultinterfaceipidx] Then
                Local $physical_address = StringSplit(StringLeft(StringReplace($resultinterfaceiptemp[$resultinterfaceipidx], 'Physical Address:', ''), 17), '-', 1)
                For $macidx = 0 To 5
                    GUICtrlSetData($mac[$macidx], $physical_address[$macidx + 1])
                Next
            EndIf
        Next
        $resultinterfaceip = ''
        $interfacepid = Run('netsh interface ip show config ' & '"' & $interface_ & '"', '', @SW_HIDE, $stdout_child)
        Do
            $resultinterfaceip &= StdoutRead($interfacepid)
        Until @error
        $resultinterfaceip = StringReplace(StringReplace($resultinterfaceip, @CR, ''), @LF, @CRLF)
        Do
            $resultinterfaceip = StringReplace($resultinterfaceip, '  ', ' ')
        Until $resultinterfaceip = StringReplace($resultinterfaceip, '  ', ' ')
        Do
            $resultinterfaceip = StringReplace($resultinterfaceip, ' : ', ':')
        Until $resultinterfaceip = StringReplace($resultinterfaceip, ' : ', ':')
        Do
            $resultinterfaceip = StringReplace($resultinterfaceip, ' .', '')
        Until $resultinterfaceip = StringReplace($resultinterfaceip, ' .', '')
        Do
            $resultinterfaceip = StringReplace($resultinterfaceip, ' :', ':')
        Until $resultinterfaceip = StringReplace($resultinterfaceip, ' :', ':')
        Do
            $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & @CRLF, @CRLF)
        Until $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & @CRLF, '')
        Do
            $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & ' ', @CRLF)
        Until $resultinterfaceip = StringReplace($resultinterfaceip, @CRLF & ' ', @CRLF)
        If StringRight($resultinterfaceip, 2) = @CRLF Then $resultinterfaceip = StringTrimRight($resultinterfaceip, 2)
        If StringReplace($resultinterfaceip, 'DHCP enabled: Yes', '') <> $resultinterfaceip Then
            GUICtrlSetState($newdhcpip, $gui_checked)
            DhcpIP()
        EndIf
        If StringReplace($resultinterfaceip, 'DHCP enabled: Yes', '') = $resultinterfaceip Then
            GUICtrlSetState($newmanip, $gui_checked)
            ManuallyIP()
        EndIf
        If StringReplace($resultinterfaceip, 'DNS servers configured through DHCP', '') <> $resultinterfaceip Then
            GUICtrlSetState($newdhcpdns, $gui_checked)
            DhcpDNS()
        EndIf
        If StringReplace($resultinterfaceip, 'DNS servers configured through DHCP', '') = $resultinterfaceip Then
            GUICtrlSetState($newmandns, $gui_checked)
            ManDNS()
        EndIf
        If StringReplace($resultinterfaceip, 'WINS servers configured through DHCP', '') <> $resultinterfaceip Then
            GUICtrlSetState($newdhcpwins, $gui_checked)
            DhcpWins()
        EndIf
        If StringReplace($resultinterfaceip, 'WINS servers configured through DHCP', '') = $resultinterfaceip Then
            GUICtrlSetState($newmanwins, $gui_checked)
            ManWins()
        EndIf
    EndIf
EndFunc   ;==>GetInterfaceIP
Func Finish_New()
    Local $focusctrl = 0, $profilename = GUICtrlRead($newprofilename)
    $profilename = _Iif(_StringToHex(StringLower($profilename)) <> _StringToHex($profilename), $profilename, _
            StringUpper(StringLeft($profilename, 1)) & StringLower(StringTrimLeft($profilename, 1)))
    Local $regprofile = 'HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profilename
    Local $dictionary = '0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'
    If StringLen($profilename) = 0 Or StringInStr('_0123456789', StringLeft($profilename, 1)) > 0 Then
        $focusctrl = 1
        GUICtrlSetState($newprofilename, $gui_focus)
    EndIf
    If $focusctrl = 0 Then
        For $newidx = 1 To StringLen($profilename)
            Local $stringmid = StringMid($profilename, $newidx, 1)
            If StringInStr($dictionary, $stringmid, 1) < 1 Then
                $focusctrl = 1
                GUICtrlSetState($newprofilename, $gui_focus)
                ExitLoop
            EndIf
        Next
    EndIf
    If $focusctrl = 0 Then
        For $newidx = 1 To 500
            Local $profilesaved = RegEnumKey('HKEY_CURRENT_USER\Software\NetworkProfiles', $newidx)
            If @error <> 0 Then ExitLoop
            If $profilesaved = $profilename Then
                $focusctrl = 1
                GUICtrlSetState($newprofilename, $gui_focus)
            EndIf
        Next
    EndIf
    If $focusctrl = 0 And GUICtrlRead($newmanip) = 1 Then
        If $focusctrl = 0 Then $focusctrl = VerifAddress(2, 5)
        If $focusctrl = 0 Then $focusctrl = VerifAddress(6, 9)
        If $focusctrl = 0 Then $focusctrl = VerifAddress(10, 13)
    EndIf
    If $focusctrl = 0 And GUICtrlRead($newmandns) = 1 Then
        If $focusctrl = 0 Then $focusctrl = VerifAddress(14, 17)
        If $focusctrl = 0 Then $focusctrl = VerifAddress(18, 21)
    EndIf
    If $focusctrl = 0 And GUICtrlRead($newmanwins) = 1 Then
        $focusctrl = VerifAddress(22, 25)
    EndIf
    If $focusctrl = 0 And GUICtrlRead($proxycheck) = 1 Then
        Local $proxyread = GUICtrlRead($proxy)
        If $proxyread <> _INetExplorerCapable($proxyread) Or $proxyread = '' Then
            $focusctrl = 1
            GUICtrlSetState($proxy, $gui_focus)
        EndIf
    EndIf
    If $focusctrl = 0 And GUICtrlRead($maccheck) = 1 Then
        For $newidx = 0 To 5
            Local $macread = GUICtrlRead($mac[$newidx])
            If $macread = '00'  Then ContinueLoop
            If Dec($macread) = 0 Or StringLen($macread) <> 2 Then
                $focusctrl = 1
                GUICtrlSetState($mac[$newidx], $gui_focus)
                ExitLoop
            EndIf
        Next
    EndIf
    If $focusctrl = 0 Then
        $treeview1_profile = GUICtrlCreateTreeViewItem(_Iif(_StringToHex(StringLower($profilename)) <> _StringToHex($profilename), $profilename, _
                StringUpper(StringLeft($profilename, 1)) & StringLower(StringTrimLeft($profilename, 1))), $maintreeview1)
        _GUICtrlTreeViewExpand($treeview1)
        RegWrite($regprofile, 'NetConnectionId', 'REG_SZ', GUICtrlRead($adapterchoose))
        Select
            Case GUICtrlRead($newdhcpip) = 4
                RegWrite($regprofile, 'IP Settings', 'REG_SZ', 'Manually Configured')
                RegWrite($regprofile, 'IP', 'REG_SZ', _GUICtrlIpAddressGet($newip))
                RegWrite($regprofile, 'Subnet', 'REG_SZ', _GUICtrlIpAddressGet($newsubnet))
                RegWrite($regprofile, 'Gateway', 'REG_SZ', _Iif(_GUICtrlIpAddressGet($newgateway) = '0.0.0.0', '', _GUICtrlIpAddressGet($newgateway)))
            Case Else
                RegWrite($regprofile, 'IP Settings', 'REG_SZ', 'Assigned by DHCP')
                RegWrite($regprofile, 'IP', 'REG_SZ', '')
                RegWrite($regprofile, 'Subnet', 'REG_SZ', '')
                RegWrite($regprofile, 'Gateway', 'REG_SZ', '')
        EndSelect
        Select
            Case GUICtrlRead($newdhcpdns) = 4
                RegWrite($regprofile, 'DNS Settings', 'REG_SZ', 'Manually Configured')
                RegWrite($regprofile, 'DNS_1', 'REG_SZ', _Iif(_GUICtrlIpAddressGet($newdns1) = '0.0.0.0', '', _GUICtrlIpAddressGet($newdns1)))
                RegWrite($regprofile, 'DNS_2', 'REG_SZ', _Iif(_GUICtrlIpAddressGet($newdns2) = '0.0.0.0', '', _GUICtrlIpAddressGet($newdns2)))
            Case Else
                RegWrite($regprofile, 'DNS Settings', 'REG_SZ', 'Assigned by DHCP')
                RegWrite($regprofile, 'DNS_1', 'REG_SZ', '')
                RegWrite($regprofile, 'DNS_2', 'REG_SZ', '')
        EndSelect
        Select
            Case GUICtrlRead($newdhcpwins) = 4
                RegWrite($regprofile, 'WINS Settings', 'REG_SZ', 'Manually Configured')
                RegWrite($regprofile, 'WINS', 'REG_SZ', _Iif(_GUICtrlIpAddressGet($newwins) = '0.0.0.0', '', _GUICtrlIpAddressGet($newwins)))
            Case Else
                RegWrite($regprofile, 'WINS Settings', 'REG_SZ', 'Assigned by DHCP')
                RegWrite($regprofile, 'WINS', 'REG_SZ', '')
        EndSelect
        Select
            Case GUICtrlRead($proxycheck) = 1
                RegWrite($regprofile, 'ProxyServer', 'REG_SZ', GUICtrlRead($proxy) & _Iif(GUICtrlRead($port) = '', '', ':' & GUICtrlRead($port)))
            Case Else
                RegWrite($regprofile, 'ProxyServer', 'REG_SZ', '')
        EndSelect
        Select
            Case GUICtrlRead($maccheck) = 1
                Local $macread = ''
                For $newidx = 0 To 5
                    $macread &= GUICtrlRead($mac[$newidx])
                Next
                RegWrite($regprofile, 'Physical Address', 'REG_SZ', $macread)
            Case Else
                RegWrite($regprofile, 'Physical Address', 'REG_SZ', '')
        EndSelect
        If _GUICtrlIpAddressGet($newdns1) = '0.0.0.0'  And _GUICtrlIpAddressGet($newdns2) = '0.0.0.0'  And _
                GUICtrlRead($newdhcpip) = 1 Then RegWrite($regprofile, 'DNS Settings', 'REG_SZ', 'Assigned by DHCP')
        If _GUICtrlIpAddressGet($newdns1) = '0.0.0.0'  And _GUICtrlIpAddressGet($newdns2) <> '0.0.0.0'  And GUICtrlRead($newmandns) = 1 Then
            RegWrite($regprofile, 'DNS_1', 'REG_SZ', _GUICtrlIpAddressGet($newdns2))
            RegWrite($regprofile, 'DNS_2', 'REG_SZ', '')
        EndIf
        If _GUICtrlIpAddressGet($newwins) = '0.0.0.0'  And GUICtrlRead($newdhcpip) = 1 Then RegWrite($regprofile, 'WINS Settings', 'REG_SZ', 'Assigned by DHCP')
        _GUICtrlTreeViewSort($treeview1)
        RegWrite($regprofile, 'Caption', 'REG_SZ', $caption)
        DeleteNew()
    EndIf
EndFunc   ;==>Finish_New
Func VerifAddress($min, $max)
    Local $guictrladdress = '', $bufferaddress = ''
    If $min = 2 Then $guictrladdress = $newip
    If $min = 6 Then $guictrladdress = $newsubnet
    If $min = 10 Then $guictrladdress = $newgateway
    If $min = 14 Then $guictrladdress = $newdns1
    If $min = 18 Then $guictrladdress = $newdns2
    If $min = 22 Then $guictrladdress = $newwins
    For $newidx_ = $max To $min Step - 1
        $bufferaddress &= ControlGetText('New', '', 'Edit' & $newidx_)
    Next
    If $bufferaddress = '' Then
        If $min = 10 Or $min = 14 Or $min = 18 Or $min = 22 Then Return 0
    EndIf
    For $newidx_ = $max To $min Step - 1
        If StringLen(ControlGetText('New', '', 'Edit' & $newidx_)) < 1 Then
            ControlFocus('New', '', 'Edit' & $newidx_)
            Return 1
        EndIf
        If ControlGetText('New', '', 'Edit' & $newidx_) - 0 = 0 And $newidx_ = $max Then
            ControlSetText('New', '', 'Edit' & $newidx_, '')
            ControlFocus('New', '', 'Edit' & $newidx_)
            Return 1
        EndIf
        ControlSetText('New', '', 'Edit' & $newidx_, ControlGetText('New', '', 'Edit' & $newidx_) - 0)
    Next
    Return 0
EndFunc   ;==>VerifAddress
Func _INetExplorerCapable($s_iestring)
    If StringLen($s_iestring) <= 0 Then
        Return ''
        SetError(1)
    Else
        Local $s_iereturn
        Local $i_iecount
        Local $n_iechar
        For $i_iecount = 1 To StringLen($s_iestring)
            $n_iechar = '0x' & Hex(Asc(StringMid($s_iestring, $i_iecount, 1)), 2)
            If $n_iechar < 0x21 Or $n_iechar = 0x25 Or $n_iechar = 0x2f Or $n_iechar > 0x7f Then
                $s_iereturn = $s_iereturn & '%' & StringRight($n_iechar, 2)
            Else
                $s_iereturn = $s_iereturn & Chr($n_iechar)
            EndIf
        Next
        Return $s_iereturn
    EndIf
EndFunc   ;==>_INetExplorerCapable
Func DeleteProfile()
    If $treeviewsel <> "Profile's Name:"  Then
        DllCall("user32.dll", "int", "KillTimer", "hwnd", $maingui, "int_ptr", 50)
        WinSetState('Network profiles', '', @SW_DISABLE)
        Local $ansdel = MsgBox(262180, $treeviewsel & ' ' & Chr(149) & ' ' & RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'NetConnectionId'), 'Are you sure you want to detele the selected profile?')
        If $ansdel = 6 Then
            RegDelete('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel)
            _GUICtrlTreeViewDeleteItem($maingui, $treeview1)
            GUICtrlSetState($maintreeview1, $gui_focus)
            _GUICtrlTreeViewSetState($treeview1, $maintreeview1, $tvis_bold)
            _GUICtrlTreeViewDeleteAllItems($treeview2)
        EndIf
        WinSetState('Network profiles', '', @SW_ENABLE)
        DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
        WinActivate('Network profiles')
        DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf
EndFunc   ;==>DeleteProfile
Func _RunDOS($scommand)
    Return RunWait(@ComSpec & " /C " & $scommand, "", @SW_HIDE)
EndFunc   ;==>_RunDOS
Func ApplyProfile()
    If $treeviewsel <> "Profile's Name:"  Then
        Local $availableinterface = False
        Local $netconnname = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'NetConnectionId')
        Local $netconncaption = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'Caption')
        DllCall("user32.dll", "int", "KillTimer", "hwnd", $maingui, "int_ptr", 50)
        WinSetState('Network profiles', '', @SW_DISABLE)
        WinSetState('Network profiles', '', @SW_HIDE)
        TrayTip('', 'Please wait...', 60)
        Local $netconnavailable = GetNetworkAdapters()
        For $interfaceidx = 1 To $netconnavailable[0]
            If $netconnname = $netconnavailable[$interfaceidx] Then
                Local $colitems = $objwmiservice.ExecQuery ("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $netconnavailable[$interfaceidx] & "'", 'WQL', 0x30)
                For $objitem In $colitems
                    If $netconncaption = StringLeft(StringTrimLeft($objitem.caption, 5), 4) Then
                        $availableinterface = True
                        ExitLoop
                    EndIf
                Next
            EndIf
            DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
            If $availableinterface Then
                ApplyOnInterface($treeviewsel, $netconnname, $netconncaption)
                ExitLoop
            EndIf
        Next
        If Not $availableinterface Then
            AnotherInterface($treeviewsel, $netconnavailable)
        EndIf
    EndIf
EndFunc   ;==>ApplyProfile
Func ApplyOnInterface($profile_selected, $conn_name, $conn_caption)
    Local $target = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\' & $conn_caption, 'NetCfgInstanceId')
    Local $settingsip = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'IP Settings')
    Select
        Case $settingsip = 'Assigned by DHCP'
            _RunDOS('netsh interface ip set address "' & $conn_name & '" dhcp')
        Case Else
            Local $setip = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'IP')
            Local $setsubnet = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'Subnet')
            Local $setgateway = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'Gateway')
            If $setgateway = '' Then _RunDOS('netsh interface ip set address "' & $conn_name & '" static ' & $setip & ' ' & $setsubnet & ' none')
            If $setgateway <> '' Then _RunDOS('netsh interface ip set address "' & $conn_name & '" static ' & $setip & ' ' & $setsubnet & ' ' & $setgateway & ' 20')
    EndSelect
    Local $settingsdns = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'DNS Settings')
    Select
        Case $settingsdns = 'Assigned by DHCP'
            _RunDOS('netsh interface ip set dns "' & $conn_name & '" dhcp')
        Case Else
            Local $setdns1 = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'DNS_1')
            Local $setdns2 = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'DNS_2')
            If $setdns1 <> '' Then _RunDOS('netsh interface ip set dns "' & $conn_name & '" static ' & $setdns1)
            If $setdns2 <> '' Then _RunDOS('netsh interface ip add dns "' & $conn_name & '" ' & $setdns2 & ' index=2')
    EndSelect
    Local $settingswins = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'WINS Settings')
    Select
        Case $settingswins = 'Assigned by DHCP'
            _RunDOS('netsh interface ip set wins "' & $conn_name & '" dhcp')
        Case Else
            Local $setwins = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'WINS')
            If $setwins = '' Then _RunDOS('netsh interface ip set wins "' & $conn_name & '" static none')
            If $setwins <> '' Then _RunDOS('netsh interface ip set wins "' & $conn_name & '" static ' & $setwins)
    EndSelect
    Local $proxyserver = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'ProxyServer')
    Select
        Case $proxyserver = ''
            RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings', 'ProxyEnable', 'REG_DWORD', 0)
            RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings', 'ProxyServer')
        Case Else
            RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings', 'ProxyServer', 'REG_SZ', $proxyserver)
            RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings', 'ProxyEnable', 'REG_DWORD', 1)
    EndSelect
    Local $physicaladdress = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $profile_selected, 'Physical Address')
    Local $currentphysicaladdress = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\' & $conn_caption, 'NetworkAddress')
    If $currentphysicaladdress <> $physicaladdress Then
        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\' & $conn_caption, 'NetworkAddress', 'REG_SZ', $physicaladdress)
        NetAdapterChangeStatus($conn_name, 'Disable')
        Sleep(7500)
        NetAdapterChangeStatus($conn_name, 'Enable')
        Sleep(7500)
    EndIf
    RegDelete('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\' & $target, 'DefaultGatewayMetric')
    RegDelete('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\' & $target, 'InterfaceMetric')
    GUICtrlSetState($maintreeview1, $gui_focus)
    _GUICtrlTreeViewSetState($treeview1, $maintreeview1, $tvis_bold)
    WinSetState('Network profiles', '', @SW_SHOW)
    WinSetState('Network profiles', '', @SW_ENABLE)
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
    WinActivate('Network profiles')
    TrayTip('', '', 1)
    DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndFunc   ;==>ApplyOnInterface
Func AnotherInterface($profile_selected, $conn_available)
    TrayTip('', '', 1)
    If $conn_available[1] = '' Then
        MsgBox(262144 + 64, '', ' No Available Network Connection')
        GUICtrlSetState($maintreeview1, $gui_focus)
        _GUICtrlTreeViewSetState($treeview1, $maintreeview1, $tvis_bold)
        WinSetState('Network profiles', '', @SW_SHOW)
        WinSetState('Network profiles', '', @SW_ENABLE)
        DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
        WinActivate('Network profiles')
        TrayTip('', '', 1)
        DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
        Return 0
    EndIf
    $guianotherinterface = GUICreate("Network Connections Available", 240, 198, -1, -1, $ws_sysmenu, $ws_ex_toolwindow + $ws_ex_topmost)
    $list_available_conn = GUICtrlCreateListView('NetworkConnectionID', 5, 5, 224, 130, $lvs_singlesel + $lvs_sortascending + $lvs_nosortheader + $lvs_showselalways, $ws_ex_clientedge)
    _GUICtrlListViewSetColumnWidth($list_available_conn, 0, 200)
    For $connidx = 1 To $conn_available[0]
        GUICtrlCreateListViewItem($conn_available[$connidx], $list_available_conn)
    Next
    GUISetOnEvent($gui_event_close, 'CloseGuiAnotherInterface', $guianotherinterface)
    $anotherinterfbutton = GUICtrlCreateButton('OK', 87, 145, 60, 20, $bs_flat)
    GUICtrlSetOnEvent($anotherinterfbutton, 'ChooseAnotherInterfaceOk')
    GUISetState(@SW_SHOW, $guianotherinterface)
EndFunc   ;==>AnotherInterface
Func CloseGuiAnotherInterface()
    GUIDelete($guianotherinterface)
    GUICtrlSetState($maintreeview1, $gui_focus)
    _GUICtrlTreeViewSetState($treeview1, $maintreeview1, $tvis_bold)
    WinSetState('Network profiles', '', @SW_SHOW)
    WinSetState('Network profiles', '', @SW_ENABLE)
    DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
    WinActivate('Network profiles')
    TrayTip('', '', 1)
    DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndFunc   ;==>CloseGuiAnotherInterface
Func ChooseAnotherInterfaceOk()
    Local $netconidselected = _GUICtrlListViewGetItemText($list_available_conn)
    If $netconidselected <> '' Then
        Local $colitems = $objwmiservice.ExecQuery ("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $netconidselected & "'", 'WQL', 0x30)
        For $objitem In $colitems
            Local $conncaption = StringLeft(StringTrimLeft($objitem.caption, 5), 4)
        Next
        GUISetState(@SW_HIDE, $guianotherinterface)
        TrayTip('', 'Please wait...', 60)
        ApplyOnInterface($treeviewsel, $netconidselected, $conncaption)
        CloseGuiAnotherInterface()
    EndIf
EndFunc   ;==>ChooseAnotherInterfaceOk
Func ReplaceNetConnIDInProfile()
    If $treeviewsel <> "Profile's Name:"  Then
        Local $netconnname = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'NetConnectionId')
        Local $netconncaption = RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'Caption')
        DllCall("user32.dll", "int", "KillTimer", "hwnd", $maingui, "int_ptr", 50)
        WinSetState('Network profiles', '', @SW_DISABLE)
        WinSetState('Network profiles', '', @SW_HIDE)
        TrayTip('', 'Please wait...', 60)
        Local $netconnavailable = GetNetworkAdapters()
        DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
        Replace_AnotherInterface($treeviewsel, $netconnavailable)
    EndIf
EndFunc   ;==>ReplaceNetConnIDInProfile
Func Replace_AnotherInterface($profile_selected, $conn_available)
    TrayTip('', '', 1)
    If $conn_available[1] = '' Then
        MsgBox(262144 + 64, '', ' No Available Network Connection')
        GUICtrlSetState($maintreeview1, $gui_focus)
        _GUICtrlTreeViewSetState($treeview1, $maintreeview1, $tvis_bold)
        WinSetState('Network profiles', '', @SW_SHOW)
        WinSetState('Network profiles', '', @SW_ENABLE)
        DllCall("User32.dll", "int", "SetTimer", "hwnd", $maingui, "int", 50, "int", 5000, "int", 0)
        WinActivate('Network profiles')
        TrayTip('', '', 1)
        DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
        Return 0
    EndIf
    $guianotherinterface = GUICreate("Network Connections Available", 240, 198, -1, -1, $ws_sysmenu, $ws_ex_toolwindow + $ws_ex_topmost)
    $list_available_conn = GUICtrlCreateListView('NetworkConnectionID', 5, 5, 224, 130, $lvs_singlesel + $lvs_sortascending + $lvs_nosortheader + $lvs_showselalways, $ws_ex_clientedge)
    _GUICtrlListViewSetColumnWidth($list_available_conn, 0, 200)
    For $connidx = 1 To $conn_available[0]
        GUICtrlCreateListViewItem($conn_available[$connidx], $list_available_conn)
    Next
    GUISetOnEvent($gui_event_close, 'CloseGuiAnotherInterface', $guianotherinterface)
    $anotherinterfbutton = GUICtrlCreateButton('OK', 87, 145, 60, 20, $bs_flat)
    GUICtrlSetOnEvent($anotherinterfbutton, 'ReplaceAnotherInterfaceOk')
    GUISetState(@SW_SHOW, $guianotherinterface)
EndFunc   ;==>Replace_AnotherInterface
Func ReplaceAnotherInterfaceOk()
    Local $netconidselected = _GUICtrlListViewGetItemText($list_available_conn)
    If $netconidselected <> '' Then
        Local $colitems = $objwmiservice.ExecQuery ("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $netconidselected & "'", 'WQL', 0x30)
        For $objitem In $colitems
            Local $conncaption = StringLeft(StringTrimLeft($objitem.caption, 5), 4)
        Next
        Local $replaceyesno = MsgBox(262180, 'Profile: ' & $treeviewsel, 'REPLACE' & @CRLF & @TAB & _
                RegRead('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'NetConnectionId') & @CRLF & 'WITH' & @CRLF & @TAB & $netconidselected)
        If $replaceyesno = 6 Then
            RegWrite('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'NetConnectionId', 'REG_SZ', $netconidselected)
            RegWrite('HKEY_CURRENT_USER\Software\NetworkProfiles\' & $treeviewsel, 'Caption', 'REG_SZ', $conncaption)
            CloseGuiAnotherInterface()
        EndIf
    EndIf
EndFunc   ;==>ReplaceAnotherInterfaceOk
Func _StringToHex($strchar)
    Local $arychar, $i, $idec, $hchar, $strhex
    $arychar = StringSplit($strchar, "")
    For $i = 1 To $arychar[0]
        $idec = Asc($arychar[$i])
        $hchar = Hex($idec, 2)
        $strhex = $strhex & $hchar
    Next
    Return $strhex
EndFunc   ;==>_StringToHex
Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites



Nevermind I found it.

this is my version.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

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
Sign in to follow this  
Followers 0