Jump to content

wowmarkb

Active Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by wowmarkb

  1. If I remember correctly, back in 2008 when I started playing with this little tool, the @IPAddress did not accurately give the current IP. I forget how I came across this but, I wanted to find another way. (I think I set some static ip address and it could read it correctly.)
  2. I can understand some of what is in the script. Like MsgBox- I have played with settings so I know how to change appearance, the GUI- size and placemwent, colors, button press action- but how to make it read the IP Address and then put it in a message box- that's where I needed help. Now that I have your script I can kinda see how it works. Before, you had a Dim statment- I read up on that and now, this version has array statements so, a little differrent.
  3. guinness, the script on this forum page (page 3) works fine, no errors. I am now trying to put it into the previous script (the one with the GUI and all the buttons) and make the "Check Addresses" button when pressed, run this latest script. Last night I removed some old lines we had about description, IP Address, etc. from the GUI script but, it either opened a blank window or, this new message window opened without waiting for a button press. So, I need to link the lines about button press of the GUI script to this new script for this new message window to open. After I get home from work, I should be able to get it all working together since I am getting an education on what the lines of code are doing. FYI- I work at a Cable TV/Internet provider and help people get back on the Internet.
  4. Guinness - Thanks, it works great. This little tool will help my customers complete the tasks in the book I am writing about fixing your Internet connection. I tried to add to your last script- I just kept getting too many errors. Thanks again.
  5. We are almost there! OK, I had to change some $aArray[$A] numbers, the [x] value, to match the label on the second window that pops up because they were showing the wrong data. For example: Default Gateway had the MAC Address listed next to it, DNS Servers had the Default Gaeway listed and the MAC had the DNS Servers listed. The numbers should be: Description [0], IP Address [1], Default Gateway [3], DNS Servers [4], Mac [2], Obtain DNS Automatically [5]. The other thing I changed was True and False were backwards. (When "Nameserver" has an address inside, it means not set to "Obtaion DNS Automatically". Here's my changes: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Array.au3> Global $aArray = _IPDetails(), $sData _ArrayDisplay($aArray) ; First box opens- "List View Display" For $A = 1 To $aArray[0][0] $sData &= "Description: " & $aArray[$A][0] & @CRLF & "IP Address: " & $aArray[$A][1] & @CRLF & "Default Gateway: " & _ $aArray[$A][3] & @CRLF & "DNS Servers: " & $aArray[$A][4] & @CRLF & "MAC: " & $aArray[$A][2] & @CRLF & "Obtain DNS Automatically: " & $aArray[$A][5] & @CRLF & @CRLF Next $sData = StringTrimRight($sData, 4) MsgBox(0, "Address Information", $sData) ; Second box opens showing the data in a neat format Func _IPDetails() Local $iCount = 0 Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[1][6] = [[0, 6]] If IsObj($oColItems) Then For $oObjectItem In $oColItems $aReturn[0][0] += 1 $iCount += 1 If $aReturn[0][0] <= $iCount + 1 Then ReDim $aReturn[$aReturn[0][0] * 2][$aReturn[0][1]] EndIf $aReturn[$iCount][0] = _IsString($oObjectItem.Description) $aReturn[$iCount][1] = _IsString($oObjectItem.IPAddress(0)) $aReturn[$iCount][2] = _IsString($oObjectItem.MACAddress) $aReturn[$iCount][3] = _IsString($oObjectItem.DefaultIPGateway(0)) $aReturn[$iCount][4] = _IsString(_WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ")) ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking. $aReturn[$iCount][5] = _WMIRegRead($oObjectItem.SettingID) ; "Obtain DNS Server Automatically" setting - "True" means no address entered Next ReDim $aReturn[$aReturn[0][0] + 1][$aReturn[0][1]] Return $aReturn EndIf Return SetError(1, 0, $aReturn) EndFunc ;==>_IPDetails Func _WMIRegRead($iGUID) If RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $iGUID & "\", "NameServer") = "" Then Return True EndIf Return False EndFunc ;==>_WMIRegRead Func _IsString($sString) If IsString($sString) Then Return $sString EndIf Return "Not Available" EndFunc ;==>_IsString Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "Not Available") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString Now, in the previous version we had "Obtain IP Address Automatically" listed (the Value was DHCPEnabled) and we called it "Auto IP" in the message box. When I try to add anything like: $aReturn[$iCount][5] = _IsString($oObjectItem.DHCPEnabled) and change this line: $aReturn[$iCount][5] = _WMIRegRead($oObjectItem.SettingID) ... to a [6], I get this error: (33) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aReturn[$iCount][6] = _WMIRegRead($oObjectItem.SettingID) ^ ERROR ..no matter what other values I change. I even tried to add another WMIRegRead line but, it didn't like 2 lines of WMIRegRead or, it would only read one but, not both. How can we add "Obtain IP Address Automatically" and show in the message box right above "Obtain DNS Server Automatically"? Thanks
  6. Thanks, guinness. katoNkatoNK- I'll take a look. I feel so close to the answer, it may be at one of these sites: Good info on RegRead: http://windowssecrets.com/forums/showthread.php/82437-User-Friendly-Access-of-Program-Version
  7. Thanks guinness. Unfortunately, your last suggestion only gives "Not Available" for all three adapters. All I want it to do is read a value in the registry and print "True" if the value has no entry. If there is any data found, print "False". Basically, I want to tell the user if "Obtain DNS Automatically" is selected or if a DNS address has been entered. Everything else works great but, right now you cannot tell if the DNS Address was obtained "Automatically" or entered manually. I tried tweaking your last suggestion but this version always says "True"- even though my Internet Protocol Version 4 (TCP/IPv4) has a DNS entered manually for one Ethernet card. FYI- I have 2 Ethernet cards and a Wireless Adapter installed so that if users have a similar configuration, it will have all the adapters listed in the message window with the details. (I could just do ipconfig/all but, I think it has too much info for the average user and the message window looks more professional:) My OS is Vista but, I want it to work on WinXP, Vista & Win7. (Testing on Vista right now.) Your original section: Dim $aInterface [5] For $i= 1 to 5 ; Max 5 Interfaces $var = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $i) If @error <> 0 then ExitLoop $aInterface [$i] = $var Next For $i = 1 To UBound ($aInterface) - 1 If RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface[$i], "NameServer") = "" And @error = 0 Then $aReturn[6] = "Auto DNS: " & @TAB & "True" ; If "NameServer" is empty, "True" means "Obtain DNS Automatically" is selected ElseIf RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface[$i], "NameServer") <> "" And @error = 0 Then $aReturn[6] = "Auto DNS: " & @TAB & "False" ; If "NameServer" has an address, "False" means "Use the following DNS Addess" is selected Else $aReturn[6] = "Auto DNS: " & @TAB & "Not Available" EndIf Whole script with "Tweaked" section ("Tweaked" section starts about line 215): #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $Parent1 = GUICreate("GBON", 170, 520, 500) ; width, height, position on screen from left GUICtrlCreateLabel("Wait 10 sec. after clicking", 20, 20) ; position on screen from left, down from top GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ver = GUICtrlCreateButton ("Windows Version", -125, 15, 120, 25) ; position on screen from left, spaces down, button width, button height GUICtrlSetOnEvent(-1, "verPressed") $nc1 = GUICtrlCreateButton ("Network Connections", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "NC1Pressed") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "RenewPressed") GUISetState(@SW_SHOW) GUICtrlCreateLabel("Wait! Renew may" & @CRLF & "take up to 3 min.", -105, 10) ; position on screen from left, down from top GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $flush = GUICtrlCreateButton ("Flush DNS", -135, 15, 120, 25) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("GBON Tool, Ver 3" & @CRLF & "© Mark Burch, 2011", -105, 15) ; diff background color, winver works different, shows all enabled network adapter addresses ; added note about renew ip, changed dimensions, added comments in script ; thanks to users in the AutoIt Forum: sahsanu, guinness, Monamo, MrCreatoR, FreeFry, Kademlia, LIMITER, Squirrely1, DickG, ChrisBair GUISetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) Wend Func verPressed() Run("winver") EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func NC1Pressed() Run("control ncpa.cpl") WinWait("Network Connections", "", 5) EndFunc Func IP1Pressed() MsgBox(64, "Check Addresses",_IPDetails()) ; open a widow that shows all enabled network adapters EndFunc Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Renew IP Address",_IPDetails()) ; open a widow that shows all enabled network adapters EndFunc Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) ;flush the DNS EndFunc ;Function Resets IP & DNS Addresses to "Obtain Automatically" then, Resets TCP/IP & Winsock. Func TCPIPPressed() $Run = Run(@ComSpec & " /c " & "netsh interface ip set address name=""Local Area Connection"" source=dhcp", "", @SW_hide) $Run = Run(@ComSpec & " /c " & "netsh interface ip set dns name=""Local Area Connection"" source=dhcp", "", @SW_hide) $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc ;Function to Ping Google from Command Line process. Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc ;Function opens Internet Options window and clicks the Advanced tab. Func InetPressed() Run("control inetcpl.cpl,@0,6") WinWait("Internet Options", "", 5) EndFunc ;Function opens Services window Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc ;Function defines Minimize and Close options for the GBON Tool Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc ; Open a Message window that shows: Description, IP Address, Default Gateway, DNS Server Addresses, ; If "Obtain IP Adress Automatically" is selected (Auto IP) and If "Obtain DNS Address Automatically" is selected (Auto DNS) MsgBox(64, "IP Addresses", _IPDetails()) Exit Global $sIPDetails = _IPDetails() Global $iExtended = @extended Switch $iExtended Case 0 $iExtended = "" Case 1 $iExtended = @CRLF & @CRLF & "The total number of adapters found was " & $iExtended & "." Case Else $iExtended = @CRLF & @CRLF & "The total number of adapters found were " & $iExtended & "." EndSwitch MsgBox(64, "IP Addresses", $sIPDetails & $iExtended) Exit Func _IPDetails() Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration", "WQL", 0x30), $aReturn[8] = [6], $sReturn = "", $iCount = 0 If IsObj($oColItems) Then For $oObjectItem In $oColItems If IsString($oObjectItem.IPAddress(0)) Then If IsString($oObjectItem.Description) Then $aReturn[1] = "Description:" & @TAB & $oObjectItem.Description Else $aReturn[1] = "Description:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.IPAddress(0)) Then $aReturn[2] = "IP Address:" & @TAB & $oObjectItem.IPAddress(0) Else $aReturn[2] = "IP Address:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.DefaultIPGateway(0)) Then $aReturn[3] = "Default Gateway:" & @TAB & $oObjectItem.DefaultIPGateway(0) Else $aReturn[3] = "Default Gateway:" & @TAB & "Not Available" EndIf If IsArray($oObjectItem.DNSServerSearchOrder()) Then $aReturn[4] = "DNS Servers:" & @TAB & _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ") Else $aReturn[4] = "DNS Servers:" & @TAB & "Not Available" EndIf If IsBool($oObjectItem.DHCPEnabled) Then $aReturn[5] = "Auto IP: " & @TAB & @TAB & $oObjectItem.DHCPEnabled Else $aReturn[5] = "Auto IP: " & @TAB & @TAB & "Not Available" EndIf Dim $aInterface [5] For $i= 1 to 5 ; Max 5 Interfaces $var = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $i) If @error <> 0 then ExitLoop $aInterface [$i] = $var Next For $i = 1 To UBound ($aInterface) - 1 $Key = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface[$i], "NameServer") If $Key = "" Then $aReturn[6] = "Auto DNS: " & @TAB & "True" ; If "NameServer" is empty, "True" means "Obtain DNS Automatically" is selected ElseIf $Key <> "" Then $aReturn[6] = "Auto DNS: " & @TAB & "False" ; If "NameServer" has an address, "False" means "Use the following DNS Addess" is selected Else $aReturn[6] = "Auto DNS: " & @TAB & "Not Available" EndIf Next $sReturn &= $aReturn[1] & @CRLF & $aReturn[2] & @CRLF & $aReturn[3] & @CRLF & $aReturn[4] & @CRLF & $aReturn[5] & @CRLF & $aReturn[6] & @CRLF & @CRLF $iCount += 1 EndIf Next If $iCount > 0 Then Return SetError(0, $iCount, StringTrimRight($sReturn, 4)) EndIf Return SetError(1, $iCount, "No Adapters Available.") EndIf Return SetError(1, 0, "No Adapters Available.") EndFunc ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString I have looked into using Global and Local instead of Dim but, to be honest, it seems like too much of a learning curve for me right now. "SyntaxCheck Prod" says there are no errors. (Yes, I use this all the time to check for errors.) I know that the value that must be looked at and processed is for: "NameServer" in the registry located at: HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\(adapter label). I just cannot figure out how to write the script that says "If the value for "NameServer" is blank, print "True" but, if it has a value (any value?) in there, print "False". Any other ideas? Thanks.
  8. Sorry, Guinness, one more task. I am trying to show if "Obtain DNS Automatically" is selected or, a static IP has been entered. Lines 208 - 222 were added. The problem is, it always shows "True"- even when a static IP has been entered (which I want to show "False". #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $Parent1 = GUICreate("GBON", 170, 520, 500) ; width, height, position on screen from left GUICtrlCreateLabel("Wait 10 sec. after clicking", 20, 20) ; position on screen from left, down from top GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ver = GUICtrlCreateButton ("Windows Version", -125, 15, 120, 25) ; position on screen from left, spaces down, button width, button height GUICtrlSetOnEvent(-1, "verPressed") $nc1 = GUICtrlCreateButton ("Network Connections", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "NC1Pressed") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "RenewPressed") GUISetState(@SW_SHOW) GUICtrlCreateLabel("Wait! Renew may" & @CRLF & "take up to 3 min.", -105, 10) ; position on screen from left, down from top GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $flush = GUICtrlCreateButton ("Flush DNS", -135, 15, 120, 25) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("GBON Tool, Ver 3" & @CRLF & "© Mark Burch, 2011", -105, 15) ; diff background color, winver works different, shows all enabled network adapter addresses ; added note about renew ip, changed dimensions, added comments in script ; thanks to users in the AutoIt Forum: sahsanu, guinness, Monamo, MrCreatoR, FreeFry, Kademlia, LIMITER, Squirrely1, DickG, ChrisBair GUISetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) Wend Func verPressed() Run("winver") EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func NC1Pressed() Run("control ncpa.cpl") WinWait("Network Connections", "", 5) EndFunc Func IP1Pressed() MsgBox(64, "Check Addresses",_IPDetails()) ; open widow shows all enabled network adapters EndFunc Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Renew IP Address",_IPDetails()) ; open widow shows all enabled network adapters EndFunc Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) EndFunc ;Function to Reset IP Address & DNS to "Obtain Automatically", Reset TCP/IP & Reset Winsock. Func TCPIPPressed() $Run = Run(@ComSpec & " /c " & "netsh interface ip set address name=""Local Area Connection"" source=dhcp", "", @SW_hide) $Run = Run(@ComSpec & " /c " & "netsh interface ip set dns name=""Local Area Connection"" source=dhcp", "", @SW_hide) $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc Func InetPressed() Run("control inetcpl.cpl,@0,6") WinWait("Internet Options", "", 5) EndFunc Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc MsgBox(64, "IP Addresses", _IPDetails()) Exit Global $sIPDetails = _IPDetails() Global $iExtended = @extended Switch $iExtended Case 0 $iExtended = "" Case 1 $iExtended = @CRLF & @CRLF & "The total number of adapters found was " & $iExtended & "." Case Else $iExtended = @CRLF & @CRLF & "The total number of adapters found were " & $iExtended & "." EndSwitch MsgBox(64, "IP Addresses", $sIPDetails & $iExtended) Exit Func _IPDetails() Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration", "WQL", 0x30), $aReturn[8] = [6], $sReturn = "", $iCount = 0 If IsObj($oColItems) Then For $oObjectItem In $oColItems If IsString($oObjectItem.IPAddress(0)) Then If IsString($oObjectItem.Description) Then $aReturn[1] = "Description:" & @TAB & $oObjectItem.Description Else $aReturn[1] = "Description:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.IPAddress(0)) Then $aReturn[2] = "IP Address:" & @TAB & $oObjectItem.IPAddress(0) Else $aReturn[2] = "IP Address:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.DefaultIPGateway(0)) Then $aReturn[3] = "Default Gateway:" & @TAB & $oObjectItem.DefaultIPGateway(0) Else $aReturn[3] = "Default Gateway:" & @TAB & "Not Available" EndIf If IsArray($oObjectItem.DNSServerSearchOrder()) Then $aReturn[4] = "DNS Servers:" & @TAB & _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ") Else $aReturn[4] = "DNS Servers:" & @TAB & "Not Available" EndIf If IsBool($oObjectItem.DHCPEnabled) Then $aReturn[5] = "Auto IP: " & @TAB & @TAB & $oObjectItem.DHCPEnabled Else $aReturn[5] = "Auto IP: " & @TAB & @TAB & "Not Available" EndIf Dim $aInterface [5] For $i= 1 to 5 ; Max 5 Interfaces $var = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $i) If @error <> 0 then ExitLoop $aInterface [$i] = $var Next For $i = 1 To UBound ($aInterface) - 1 If RegRead ("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface [$i], "NameServer") = "" Then $aReturn[6] = "Auto DNS: " & @TAB & "True" ; If "NameServer" is empty, "True" means "Obtain DNS Automatically" is selected If RegRead ("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $aInterface [$i], "NameServer") <> "" Then $aReturn[6] = "Auto DNS: " & @TAB & "False" ; If "NameServer" has an address, "False" means "Use the following DNS Addess" is selected EndIf Else $aReturn[6] = "Auto DNS: " & @TAB & "Not Available" EndIf Next $sReturn &= $aReturn[1] & @CRLF & $aReturn[2] & @CRLF & $aReturn[3] & @CRLF & $aReturn[4] & @CRLF & $aReturn[5] & @CRLF & $aReturn[6] & @CRLF & @CRLF $iCount += 1 EndIf Next If $iCount > 0 Then Return SetError(0, $iCount, StringTrimRight($sReturn, 4)) EndIf Return SetError(1, $iCount, "No Adapters Available.") EndIf Return SetError(1, 0, "No Adapters Available.") EndFunc ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString
  9. Thanks again, guinness! I actually did look for WMI stuff and "isstring". The problem is, since I do not understand what each string is doing, it's like me trying to read and understand the greek language- bunch of characters that do not make sense. I tried a coule of things that I found but because I was just taking a couple of lines, I got errors about "not defined"- so I wasn't getting enough of the script to make it work. What was it you said about 3 examples?- I loved all the scripts you provided. After I started using them, I just wanted to tweak them a bit, that's all. Before your current submission (which I will try wheh I get home from work), I could've left it alone. When all network adapters were disabled (which happens to my customers!), it had a blank window. I just wanted a message so they will see some words. Thanks again for all your work- you and all the others who sent in suggestions are awesome!
  10. Thanks guinness! Yes! OK, now a new situation came up. I disabled both Ethernet cards and the Wireless Adapter (to simulate a customer's adapter disabled- but they do not know it. When I click "Check Addresses", a message box opens but, it is blank. Is there a way to make it say "No adapters found"- or something like that? I'm not sure what value to check for. With all adapters disabled, I know that in the command window, it will not show any info, either. Maybe a string that looks for a MAC Address but, if none are found, it could print in the message box, "No adapters found". I tried adding this: If IsString($oObjectItem.MACAddress) = "" Then $aReturn[6] = "No adapters found" EndIf ..but, it did nothing- still just an open message window that is blank. Tried: If "MACAddress" = "" Then $aReturn[6] = "No adapters found" EndIf ..but, it did nothing- still just an open message window that is blank. I tried looking for something on the Internet but, nothing close to this task was found. I'm sorry, I know what I want it to do, but just don't know programing enough to know the synatx.
  11. guinness I have one request. A new change I added was to Reset both the IP Address & DNS Servers to "Obtain Automatically" when TCP/IP & Winsock button was pressed. How can I make it show if "Obtain IP Address Automatically" or "Obtain DNS Server Address Automatically" have been changed? For the "Check Addresses" button, I took out the MAC Address (which was great but I'd rather have it show if DHCP is enabled or, not - about line 188.) I tried different variations to show if DHCP was enabled but I just could not figure it out. Google search did not give me and easy answer. If I could find a way to show the status of the "Obtain IP Address Automatically" radio button, that would work. #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $Parent1 = GUICreate("GBON Tool", 170, 520, 500) ; width, height, position on screen from left GUICtrlCreateLabel("Wait 10 sec. after clicking", 20, 20) ; position on screen from left, down from top GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ver = GUICtrlCreateButton ("Windows Version", -125, 15, 120, 25) ; position on screen from left, spaces down, button width, button height GUICtrlSetOnEvent(-1, "verPressed") $nc1 = GUICtrlCreateButton ("Network Connections", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "NC1Pressed") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "RenewPressed") GUISetState(@SW_SHOW) GUICtrlCreateLabel("Wait! Renew may" & @CRLF & "take up to 3 min.", -105, 10) ; position on screen from left, down from top GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $flush = GUICtrlCreateButton ("Flush DNS", -135, 15, 120, 25) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -120, 15, 120, 25) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("GBON Tool, Ver 3" & @CRLF & "© Mark Burch, 2011", -105, 15) ; diff background color, winver works different, shows all enabled network adapter addresses ; added note about renew ip, changed dimensions, added comments in script ; thanks to users in the AutoIt Forum: sahsanu, guinness, Monamo, MrCreatoR, FreeFry, Kademlia, LIMITER, Squirrely1, DickG, ChrisBair GUISetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) Wend Func verPressed() Run("winver") EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func NC1Pressed() Run("control ncpa.cpl") WinWait("Network Connections", "", 5) EndFunc Func IP1Pressed() MsgBox(64, "Check Addresses",_IPDetails()) ; open widow shows all enabled network adapters EndFunc Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Renew IP Address",_IPDetails()) ; open widow shows all enabled network adapters EndFunc Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) EndFunc ;Function to Reset IP Address & DNS to "Obtain Automatically", Reset TCP/IP & Reset Winsock. Func TCPIPPressed() $Run = Run(@ComSpec & " /c " & "netsh interface ip set address name=""Local Area Connection"" source=dhcp", "", @SW_hide) $Run = Run(@ComSpec & " /c " & "netsh interface ip set dns name=""Local Area Connection"" source=dhcp", "", @SW_hide) $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc Func InetPressed() Run("control inetcpl.cpl,@0,6") WinWait("Internet Options", "", 5) EndFunc Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc MsgBox(64, "IP Addresses",_IPDetails()) Exit Func _IPDetails() Local $totalReturn="" Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration", "WQL", 0x30), $aReturn[6] = [5] If IsObj($oColItems) Then For $oObjectItem In $oColItems If IsString($oObjectItem.IPAddress(0)) Then If IsString($oObjectItem.Description) Then $aReturn[1] = "Description:" & @TAB & $oObjectItem.Description Else $aReturn[1] = "Description:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.IPAddress(0)) Then $aReturn[2] = "IP Address:" & @TAB & $oObjectItem.IPAddress(0) Else $aReturn[2] = "IP Address:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.DefaultIPGateway(0)) Then $aReturn[3] = "Default Gateway:" & @TAB & $oObjectItem.DefaultIPGateway(0) Else $aReturn[3] = "Default Gateway:" & @TAB & "Not Available" EndIf If IsArray($oObjectItem.DNSServerSearchOrder()) Then $aReturn[4] = "DNS Servers:" & @TAB & _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ") Else $aReturn[4] = "DNS Servers:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.DHCPEnabled) Then $aReturn[5] = "DHCP: " & @TAB & @TAB & $oObjectItem.DHCPEnabled Else $aReturn[5] = "DHCP: " & @TAB & @TAB & "Not Available" EndIf $totalReturn &= $aReturn[1] & @CRLF & $aReturn[2] & @CRLF & $aReturn[3] & @CRLF & $aReturn[4] & @CRLF & $aReturn[5] & @CRLF & @CRLF EndIf Next Return StringTrimRight($totalReturn,4) EndIf Return SetError(1, 0, $aReturn) EndFunc ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString Thanks.
  12. Thanks guinness. Don't know why but, my Dell laptop (Win7 Home Premium edition) seem to lock up. Maybe if I'd waited long enough, it would have worked OK. I decided to just have it open a message window using "winver" like I used to do it on previous version of script- which is really fast on the laptop. Now, I have tweaked the color, dimensions, etc. Try it now. #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $Parent1 = GUICreate("GBON Tool", 160, 490, 500) ; width, height, position on screen from left GUICtrlCreateLabel("Wait 10 sec. after clicking", 20, 20) ; position on screen from left, down from top GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ver = GUICtrlCreateButton ("Windows Version", -120, 15, 100, 25) ; position on screen from left, spaces down, button width, button height GUICtrlSetOnEvent(-1, "verPressed") $ip1 = GUICtrlCreateButton ("Check Addresses", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "RenewPressed") GUISetState(@SW_SHOW) GUICtrlCreateLabel("Wait! Renew may" & @CRLF & "take up to 3 min.", -95, 10) ; position on screen from left, down from top GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $flush = GUICtrlCreateButton ("Flush DNS", -105, 15, 100, 25) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 15, 100, 25) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("GBON Tool, Ver 3" & @CRLF & "© Mark Burch, 2011", -95, 15) ; diff background color, winver works different, shows all enabled network adapter addresses ; added note about renew ip, changed dimensions, added comments in script ; thanks to users in the AutoIt Forum: sahsanu, guinness, Monamo, MrCreatoR, FreeFry, Kademlia, LIMITER, Squirrely1, DickG, ChrisBair GUISetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) Wend Func verPressed() Run("winver") EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func IP1Pressed() MsgBox(64, "Check Addresses",_IPDetails()) ; open widow shows all enabled network adapters EndFunc Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Renew IP Address",_IPDetails()) ; open widow shows all enabled network adapters EndFunc Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) EndFunc Func TCPIPPressed() $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc Func InetPressed() Run("control inetcpl.cpl") WinWait("Internet Options", "", 5) EndFunc Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc MsgBox(64, "IP Addresses",_IPDetails()) Exit Func _IPDetails() Local $totalReturn="" Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration", "WQL", 0x30), $aReturn[6] = [5] If IsObj($oColItems) Then For $oObjectItem In $oColItems If IsString($oObjectItem.IPAddress(0)) Then If IsString($oObjectItem.Description) Then $aReturn[1] = "Description:" & @TAB & $oObjectItem.Description Else $aReturn[1] = "Description:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.IPAddress(0)) Then $aReturn[2] = "IP Address:" & @TAB & $oObjectItem.IPAddress(0) Else $aReturn[2] = "IP Address:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.DefaultIPGateway(0)) Then $aReturn[3] = "Default Gateway:" & @TAB & $oObjectItem.DefaultIPGateway(0) Else $aReturn[3] = "Default Gateway:" & @TAB & "Not Available" EndIf If IsArray($oObjectItem.DNSServerSearchOrder()) Then $aReturn[4] = "DNS Servers:" & @TAB & _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ") Else $aReturn[4] = "DNS Servers:" & @TAB & "Not Available" EndIf If IsString($oObjectItem.MACAddress) Then $aReturn[5] = "MAC: " & @TAB & @TAB & $oObjectItem.MACAddress Else $aReturn[5] = "MAC: " & @TAB & @TAB & "Not Available" EndIf $totalReturn &= $aReturn[1] & @CRLF & $aReturn[2] & @CRLF & $aReturn[3] & @CRLF & $aReturn[4] & @CRLF & $aReturn[5] & @CRLF & @CRLF EndIf Next Return StringTrimRight($totalReturn,4) EndIf Return SetError(1, 0, $aReturn) EndFunc ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString
  13. Thank you guinness! OK, I finally got what you mean- put the code between the tags, like this: (code goes here) . Now, the window pops open displaying everything exactly as I wanted but it did nothing else. I want it to wait until I press the "Check Addresses" button before it displays, like it did previously. (Sorry for being so picky OK, I moved these two lines that were located at lines 10 & 11, to: lines 168 & 169: MsgBox(64, "IP Addresses",_IPDetails()) Exit Now, this version is perfect!..almost. My goal is to run it on: WinXP, Vista & Win7. I just tried to run it in Win 7- nothing. I am logged in as admin. My older version (script listed below where it does not list all adapters) does work in Win7. Not sure why. Any ideas? #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) Global $aArray = _IPDetails() Global $sData = "Your IP Address: " & $aArray[1] & @LF & _ "Your Gateway Address: " & $aArray[3] & @LF & _ "You DNS Servers: " & $aArray[4] Select Case @OSVersion = "WIN_7" $Parent1 = GUICreate("GBON Tool", 180, 530, 600) GUICtrlCreateLabel("You have Windows 7" & @CRLF & @CRLF & "Wait 10 sec. after clicking", 25, 20) GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 20, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 20, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 20, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -100, 20, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 20, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case @OSVersion = "WIN_VISTA" $Parent1 = GUICreate("GBON Tool", 180, 530, 600) GUICtrlCreateLabel("You have Windows Vista" & @CRLF & @CRLF & "Click button and wait 10" & @CRLF & "sec. for window to open", 32, 20) GUISetBkColor(0x00CCFF) ; set color GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check Addresses", -118, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 20, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 20, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 20, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -100, 20, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 20, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case @OSVersion = "WIN_XP" $Parent1 = GUICreate("GBON! Tool", 180, 500, 600) GUICtrlCreateLabel("You have Windows XP" & @CRLF & "" & @CRLF & "Wait 10 sec. after clicking", 25, 20) GUISetBkColor(0x00CCFF) ; set color GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 20, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 20, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 20, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 20, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Options", -100, 20, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 20, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case Else MsgBox(48, "Unsupported OS", "This application is not designed to run on this operating system.") Exit EndSelect ; Just idle around While 1 Sleep(1000) Wend Func VerPressed() Run("winver") EndFunc Func IP1Pressed() MsgBox(0, "Your PC Addresses", $sData) ;$IP_Address = _RunStdOutRead('ipconfig /all') ;$IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") ;MsgBox(64, "Check IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Renew IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) EndFunc Func TCPIPPressed() $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc Func InetPressed() Run("control inetcpl.cpl") WinWait("Internet Options", "", 5) EndFunc Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc Func _IPDetails() Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[5] = [4] If IsObj($oColItems) Then For $oObjectItem In $oColItems If $oObjectItem.IPAddress(0) == @IPAddress1 Then $aReturn[1] = $oObjectItem.IPAddress(0) $aReturn[2] = $oObjectItem.MACAddress $aReturn[3] = $oObjectItem.DefaultIPGateway(0) $aReturn[4] = _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " and ") ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking. EndIf Next Return $aReturn EndIf Return SetError(1, 0, $aReturn) EndFunc ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString
  14. sahsanu - Thanks but, it has errors- lines 101-105 (Lines 99-105 shown below). Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\1")" MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() //////////end When I do syntax check, it says this: >C:\Program Files\AutoIt3\SciTE\..\au3check.exe "C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3" AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007 C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3(101,105) : ERROR: syntax error (illegal character) $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3(107,105) : ERROR: syntax error (illegal character) $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3(113,105) : ERROR: syntax error (illegal character) $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3(119,105) : ERROR: syntax error (illegal character) $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3(137,105) : ERROR: syntax error (illegal character) $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\My Book Feb 2011\My GBON Tool\7 May\All IPs.au3 - 5 error(s), 0 warning(s) ////////////////end Guinness, I tried using an SRE tester online but, I am clueless as to how to make it work. I added a quote on the end of: line 101 like this: $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*{:content:}quot;, "\1")" ...but that didn't work. I did change a couple of lines to the previous script that opens a DOS window and displays all the ipconfig info which is OK. It would be nice to have a message box open and give only the IP Address, Gateway, & DNS Servers for all Local Area Adapters & Wireless Adapters so that it won't be information overload to for users when they hit the Check Addresses button, that's all: ////////////start #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) Global $aArray = _IPDetails() Global $sData = "Your IP Address: " & $aArray[1] & @LF & _ "Your Gateway Address: " & $aArray[3] & @LF & _ "You DNS Servers: " & $aArray[4] Select Case @OSVersion = "WIN_7" $Parent1 = GUICreate("GBON Tool", 180, 500, 600) GUICtrlCreateLabel("You have Windows 7" & @CRLF & @CRLF & "Wait 10 sec. after clicking", 25, 20) GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 20, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 20, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 20, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -100, 20, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 20, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case @OSVersion = "WIN_VISTA" $Parent1 = GUICreate("GBON Tool", 180, 530, 600) GUICtrlCreateLabel("You have Windows Vista" & @CRLF & @CRLF & "Click button and wait 10" & @CRLF & "sec. for window to open", 32, 20) GUISetBkColor(0x00CCFF) ; set color GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check Addresses", -118, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 20, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 20, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 20, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -100, 20, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 20, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case @OSVersion = "WIN_XP" $Parent1 = GUICreate("GBON! Tool", 180, 500, 600) GUICtrlCreateLabel("You have Windows XP" & @CRLF & "" & @CRLF & "Wait 10 sec. after clicking", 25, 20) GUISetBkColor(0x00CCFF) ; set color GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check Addresses", -120, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 18, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 18, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 18, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 18, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 18, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Options", -100, 18, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 18, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case Else MsgBox(48, "Unsupported OS", "This application is not designed to run on this operating system.") Exit EndSelect ; Just idle around While 1 Sleep(1000) Wend Func VerPressed() Run("winver") EndFunc Func IP1Pressed() $CMD = "ipconfig /all" RunWait(@ComSpec & " /k " & $CMD, @WindowsDir, @SW_SHOW) EndFunc Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Renew IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) EndFunc Func TCPIPPressed() $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc Func InetPressed() Run("control inetcpl.cpl") WinWait("Internet Options", "", 5) EndFunc Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc Func _IPDetails() Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True", "WQL", 0x30), $aReturn[5] = [4] If IsObj($oColItems) Then For $oObjectItem In $oColItems If $oObjectItem.IPAddress(0) == @IPAddress1 Then $aReturn[1] = $oObjectItem.IPAddress(0) $aReturn[2] = $oObjectItem.MACAddress $aReturn[3] = $oObjectItem.DefaultIPGateway(0) $aReturn[4] = _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " and ") ; You could use _ArrayToString() but I like creating my own Functions especially when I don't need alot of error checking. EndIf Next Return $aReturn EndIf Return SetError(1, 0, $aReturn) EndFunc ;==>_IPDetails Func _WMIArrayToString($aArray, $sDelimeter = "|") If IsArray($aArray) = 0 Then Return SetError(1, 0, "") EndIf Local $iUbound = UBound($aArray) - 1, $sString For $A = 0 To $iUbound $sString &= $aArray[$A] & $sDelimeter Next Return StringTrimRight($sString, StringLen($sDelimeter)) EndFunc ;==>_WMIArrayToString /////////////////end Thanks sahsanu & guinness for your continued help.
  15. Is there a way in the IP Address message box, to show both the Local Area Adapter and the Wireless Adapter addresses? (In case a PC has both an Ethernet card & a Wireless card.) Thanks.
  16. Thanks. I have a micron of knowledge about programming. I can spell AutoIt but, I do not really understand arrays, variables, what the scripts are doing and all that. (I tried to learn Basic in the early 80's and looked at c# last year but, decided that I couldn't do it on my own.) 99.9% of my utility came from guys (& gals?) like you on this forum. Once I see the script- sometimes, I can kind of make out what it is doing and where I can make a change to make it do what I want. However, I mainly do cosmetic changes, though. Mark
  17. Thanks sahsanu- you rock! My hat's off to you and all those before you who got me to this point It works just like I had hoped it would. Thanks again! Mark
  18. More for Guinness. Here is my total script - before your suggestion. How do I integrate your script into this little utility to make it all work? //////////Start #include <GUIConstants.au3> ; This script requires full Administrative rights #requireadmin #AutoIt3Wrapper_UseAnsi=y Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) Select Case @OSVersion = "WIN_VISTA" $Parent1 = GUICreate("GBON Tool", 180, 500, 600) GUICtrlCreateLabel("You have Windows Vista" & @CRLF & "Wait 10 sec. after clicking", 25, 20) GUISetBkColor(0x33CCCC) ; set color GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check IP Address", -120, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 20, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 20, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 20, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 20, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Properties", -100, 20, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 20, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case @OSVersion = "WIN_XP" $Parent1 = GUICreate("GBON!", 165, 650, 780) GUICtrlCreateLabel("You have Windows XP" & @CRLF & "" & @CRLF & "Wait 10 sec. after clicking", 25, 20) GUISetBkColor(0x33CCCC) ; set color GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") $ip1 = GUICtrlCreateButton ("Check IP Address", -120, 18, 100, 30) GUICtrlSetOnEvent(-1, "IP1Pressed") $release = GUICtrlCreateButton ("Release IP", -100, 18, 100) GUICtrlSetOnEvent(-1, "ReleasePressed") $renew = GUICtrlCreateButton ("Renew IP", -100, 18, 100) GUICtrlSetOnEvent(-1, "RenewPressed") $flush = GUICtrlCreateButton ("Flush DNS", -100, 18, 100) GUICtrlSetOnEvent(-1, "FlushPressed") $tcpip = GUICtrlCreateButton ("TCP/IP Winsock", -100, 18, 100) GUICtrlSetOnEvent(-1, "TCPIPPressed") $ping4 = GUICtrlCreateButton ("Ping Google", -100, 18, 100) GUICtrlSetOnEvent(-1, "Ping4Pressed") $inet = GUICtrlCreateButton ("Internet Options", -100, 18, 100) GUICtrlSetOnEvent(-1, "InetPressed") $serv = GUICtrlCreateButton ("Check Services", -100, 18, 100) GUICtrlSetOnEvent(-1, "ServPressed") GUICtrlCreateLabel("Version 2" & @CRLF & "© Mark Burch, 2011", -100, 20) GUISetState(@SW_SHOW) Case Else MsgBox(48, "Unsupported OS", "This application is not designed to run on this operating system.") Exit EndSelect ; Just idle around While 1 Sleep(10) Wend Func VerPressed() Run("winver") EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func IP1Pressed() $IP_Address = _RunStdOutRead('ipconfig /all') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Check IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func ReleasePressed() $IP_Address = _RunStdOutRead('ipconfig /release') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Release IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func RenewPressed() $IP_Address = _RunStdOutRead('ipconfig /renew') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Renew IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func FlushPressed() $IP_Address = _RunStdOutRead('netsh int ip delete arpcache & ipconfig/flushdns') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Flush DNS", StringFormat("%s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func TCPIPPressed() $IP_Address = _RunStdOutRead('netsh int ip reset resetlog.txt & netsh winsock reset') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Reset TCP/IP & Winsock", StringFormat("%s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END ;Function to read from Command Line process. Func _RunStdOutRead($sRunCmd) Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Return $sStdOutRead EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func Ping4Pressed() $IP_Address = _RunStdOutRead('ping www.google.com') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Ping Out By URL", StringFormat("%s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func InetPressed() Run("control inetcpl.cpl") WinWait("Internet Options", "", 5) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func ServPressed() $File = @SystemDir & "\services.msc" Run(@SystemDir & "\mmc.exe " & $File) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) EndSelect EndFunc ///////////////End
  19. Hi Guinness. Yes- that works great! OK, now I have another request. I tried it with a wireless adapter enabled. Is there a way in the message box to show both the Local Area Adapter and the Wireless Adapter addresses? Thanks.
  20. Thanks for you inputs. I really want to use the program I have and just add a couple of lines to make it display the Gateway Address and DNS Server Addresses after the IP Address. FYI- I have tried the command @IPAddress1 before and found that sometimes it was not accurate. (In my script after this line): $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") (would this work if add something like this): $Gateway = StringRegExpReplace($Gateway, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") $DNS = StringRegExpReplace($DNS, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Check IP Address", StringFormat("Your IP Address is: %s", $IP_Address, $Gateway, $DNS)) //////(I know nothing about programming). I'd like a window that pops open with: Your IP Address: xx.xx.xx.xx Your Gateway Address: xx.xx.xx.xx You DNS Servers: xx.xx.xx.xx , xx.xx.xx.xx (or something like that) Thanks.
  21. I have a GUI with buttons. When the IP Address button is pressed, it runs the script (below) and displays the IP Address in a window. Now, I would like the window to display all of the following information: IP Address, Default Gateway & DNS Servers. What do I need to add to show them all? Thanks. /////////// Start Func IP1Pressed() $IP_Address = _RunStdOutRead('ipconfig /all') $IP_Address = StringRegExpReplace($IP_Address, "(?i)(?s).*IP.*?(\d+\.\d+\.\d+\.\d+).*$", "\1") MsgBox(64, "Check IP Address", StringFormat("Your IP Address is: %s", $IP_Address)) EndFunc ; Just idle around While 1 Sleep(10) Wend ; END /////////// End
  22. You are right. I needed the example though. Thanks, Mark
  23. Yes, that is exactly what I needed to know. When I get home, I'll try that Thanks, Mark
  24. Thanks to you both for your answers. Aaarrgghh. The last thing a "newbie" wants to hear is "Everything you need is in the Help file". I looked in the Help section and saw "@OSVersion" and "WIN_VISTA", "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95". OK, I got that much. But, what do you do with the answer? There are NO examples that tell me how to use that answer and run a script based on that value. If all I wanted was to display the computer's OS, you're right- the anwer is there. Sometimes the answewr may be right there but a "newbie" doesn't know what to do with the data. That is what is so frustrating for a "newbie"- we don't know what we're doing or sometimes even how to word the question to get the answer we're looking for. Yes, I've had many posts and I am learning. Most posts were for a routine that people gave me scripts for but, that didn't do what I wanted it to do. But hey, the community was there to help me and I got the answer- you guys/gals Rock! Oh, the script I found and posted above is at: http://www.postfinder.com/post/24307838.html How did you guys/gals learn this stuff? Thanks, Mark
×
×
  • Create New...