jguinch

Network configuration UDF

46 posts in this topic

#1 ·  Posted (edited)

Hello

Here is my network UDF. Do not yell at me if it already exists ... :'(
I hope it will be useful to someone.
Please
, let me know if you have any problem.

All functions that perform modifications required administrator rights

Functions list :

Spoiler

    _DisableNetAdapter
    _EnableDHCP
    _EnableDHCP_DNS
    _EnableNetAdapter
    _EnableStatic
    _FlushDNS
    _FlushDNSEntry
    _GetNetworkAdapterFromID
    _GetNetworkAdapterInfos
    _GetNetworkAdapterList
    _GetNetworkGUI
    _GetNetworkIDFromAdapter

    _IsWirelessAdapter
    _ReleaseDHCPLease
    _RenewDHCPLease
    _SetDNSDomain
    _SetDNSServerSearchOrder
    _SetDNSSuffixSearchOrder
    _SetDynamicDNSRegistration
    _SetGateways
    _SetWINSServer

Internal functions only :

Spoiler

_WMIDate
_Array2String
_ErrFunc

Examples :

#Include "network.au3"

; List of availables connections/cards
#Include <array.au3> ; only for _ArrayDisplay()
$infos = _GetNetworkAdapterList()
_ArrayDisplay($infos)


; Network card informations for the network connection called "Local Area Network"
$infos = _GetNetworkAdapterInfos("Local Area Network")
_ArrayDisplay($infos)

; Disable a network connection
_DisableNetAdapter("Broadcom NetLink (TM) Gigabit Ethernet")
; OR _DisableNetAdapter("Local Area Network")

; Enable a network connection
_EnableNetAdapter("Local Area Network")
; OR _EnableNetAdapter("Broadcom NetLink (TM) Gigabit Ethernet")

; Enable DHCP (for IP Address)
_EnableDHCP("Broadcom NetLink (TM) Gigabit Ethernet")
; OR _EnableDHCP("Local Area Network")

; Configure a static IP adress
_EnableStatic("Broadcom NetLink (TM) Gigabit Ethernet", "192.168.10.11", "255.255.255.0")
; OR _EnableStatic("Local Area Network", "192.168.10.11", "255.255.255.0")

; Configure the default gateway
_SetGateways("Broadcom NetLink (TM) Gigabit Ethernet", "192.168.10.1")
; OR _SetGateways("Local Area Network", "192.168.10.1")

 ; Configure DNS servers
Local $DNS_SERVERS[4] = [ "192.168.100.1", "192.168.100.2", "192.168.100.3", "192.168.100.4" ]
_SetDNSServerSearchOrder("Local Area Network", $DNS_SERVERS)
; OR _SetDNSServerSearchOrder("Broadcom NetLink (TM) Gigabit Ethernet", $DNS_SERVERS)

; Configure the DNS domain name
_SetDNSDomain ("Local Area Network", "mondomain.loc")
; OR _SetDNSDomain ("Broadcom NetLink (TM) Gigabit Ethernet", "mondomain.loc")

; Configure the DNS suffixes for all connections :
Local $DNS_SUFFIXES[2] = [ "mondomain.loc", "mydomain.priv" ]
_SetDNSSuffixSearchOrder($DNS_SUFFIXES)

; Clear the DNS cache (like ipconfig /flushdns)
_FlushDNS()

; Remove an entry from the DNS cache
_FlushDNSEntry("www.autoitscript.com")

; Configure the WINS servers (very old, now ...)
_SetWINSServer("Local Area Network", "192.168.100.251", "192.168.100.252")
; OR _SetWINSServer("Broadcom NetLink (TM) Gigabit Ethernet", "192.168.100.251", "192.168.100.252")

; Enable the two options :
; - Register this connection's address in DNS ( first parameter)
; - Use this connection's DNS suffix in DNS registration (second parameter)
_SetDynamicDNSRegistration("Local Area Network", True, True)

; Release the DHCP lease
_ReleaseDHCPLease()

; Renew the DHCP lease
_RenewDHCPLease()


Download link :  Network.au3

Edited by jguinch
3 people like this

Share this post


Link to post
Share on other sites



It is not working for me in win 7 .

1 person likes this

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

It is not working for me in win 7 .

When posting a bug report please provide a detailed description of what didn't work, system, AutoIt version (remember the @AutoItVersion trick I taught you yesterday) code you tried. Simply saying it doesn't work is counter productive.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

When posting a bug report please provide a detailed description of what didn't work, system, AutoIt version (remember the @AutoItVersion trick I taught you yesterday) code you tried. Simply saying it doesn't work is counter productive.

In this situation your script blink only and to do nothing.....See thumbnails.

i run Version Test script.

MsgBox(0,"Version Info"," Autoit version: "&@AutoItVersion&" Architecture type: "&@OSArch&" Opreating System build number: "&@OSBuild&" Service pack info: "&@OSServicePack&" Opreating System Type: "&@OSType&" Oprating System Version: "&@OSVersion) 

Result>>>>of Version Test script.

post-76662-0-33300800-1382252790_thumb.p

Edited by adnanbaloch

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

The screenshots are really unnecessary.  In the future just write to the console (ConsoleWrite()) and post the output here instead. Secondly, the example they've provided showcases everything the UDF does, so if you just ran that then no wonder it doesn't work.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

i understood guinness. Next time i shall use console write and see the result in SciTE console.

Edited by adnanbaloch

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

tip:

if is needed to post a screenshot, it is better to capture only the interested window instead of all the screen
just press "ALT"+"PRINTSCREEN" instead of only "PRINTSCREEN"
this will capture only the active windows (or popup)

1 person likes this

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

tip:

if is needed to post a screenshot, it is better to capture only the interested window instead of all the screen

just press "ALT"+"PRINTSCREEN" instead of only "PRINTSCREEN"

this will capture only the active windows (or popup)

oh good trick.thanks PincoPanco


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

thank you to tell me what does not work ...

Did you have administrator rights?

i compiled your script and run it as administrator...But result remain same. Blink only.

Edited by adnanbaloch

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

i was trying to disable network adapter. But it was not happen. 

it is not a graphical tool 

 i know.

Edited by adnanbaloch

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I know I have trouble with English, but is it so hard to ask you to post the code you used?

For me, this is OK :

#RequireAdmin
#Include "network.au3"
_DisableNetAdapter("Local Area Network") ; replace this by your network connection name or network card name
Edited by jguinch

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

 

I know I have trouble with English, but is it so hard to ask you to post the code you used?

Your English is perfect. I'm afraid the user needs to understand the etiquette involved when posting a potential bug report. Something I have tried to instruct over the course of today.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I know I have trouble with English, but is it so hard to ask you to post the code you used?

For me, this is OK :

#RequireAdmin
#Include "network.au3"
_DisableNetAdapter("Local Area Network") ; replace this by your network connection name or network card name

Thanks it works...................

Edited by adnanbaloch

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

thanks a lot of you i try.


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites

are these functions only local or can you do _GetNetworkAdapterList($remoteComputerName) ?
 

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

At present they are only local functions.

Looks like most of the funcs could support remote machines except:
_FlushDNS

_GetNetworkGUI

_GetNetworkAdapterList

_GetNetworkIDFromAdapter

_IsWirelessAdapter

I believe the _Get funcs I listed above could be modified to support Remote Machines as they rely on reg funcs.

For the other funcs all of the WMI calls define @ComputerName which would need to be changed to a parameter variable.

 

Of course you wouldn't want to run some of those funcs remotely though as they'll severe connections. :P
 

Edited by spudw2k

Share this post


Link to post
Share on other sites

flushdns could be executed with cmd... remote cmd isn't that hard :-)

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