_Chris_ Posted September 12, 2006 Share Posted September 12, 2006 I am making an ip switcher for use with remote support software, i have a dos code to change the computers ip address: netsh interface ip set address name="Wireless Network Connection" dhcp netsh interface ip set dns name="Wireless Network Connection" dhcp What i need is a way of checking whether the IP is set to auto or not. Any ideas?? Link to comment Share on other sites More sharing options...
dabus Posted September 12, 2006 Share Posted September 12, 2006 (edited) Parse ipconfig /all ... My output looks like this DHCP-aktiviert. . . . . . . . . . : Nein You could also do a RegRead at HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\??? and search for the key EnableDHCP. Edited September 12, 2006 by dabus Link to comment Share on other sites More sharing options...
_Chris_ Posted September 12, 2006 Author Share Posted September 12, 2006 Yeah i knew how to do that but How could i automate this using autoit? Link to comment Share on other sites More sharing options...
MadBoy Posted September 12, 2006 Share Posted September 12, 2006 Global $DirOutputOnce $DirOutput = Run(@ComSpec & " /c ipconfig /all", '', @SW_HIDE, 2) While 1 $DirData = StdoutRead($DirOutput) If @error Then ExitLoop If $DirData Then $DirOutputOnce &= $DirData Else Sleep(10) EndIf WEnd ; Remove spaces from output $DirOutputOnce = StringStripWS($DirOutputOnce, 3) ; Split output into array $DirSplit = StringSplit($DirOutputOnce, @CRLF, 1) For $i = 1 To $DirSplit[0] MsgBox(1,1,$DirSplit[$i]) Next Keep in mind that each language will have difftrent output. My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
MadBoy Posted September 12, 2006 Share Posted September 12, 2006 Also as dabus stated it would be even better to use REGISTRY as it's the same language in all windows versions. But you gotta play yourself with it and check in regedit what you realy need to achieve Here's sample. For $i= 1 to 10 $var = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces", $i) If @error <> 0 then ExitLoop $reg = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\" & $var, "EnableDHCP") If $reg = 1 Then $dhcp = "Yes" If $reg = 0 Then $dhcp = "No" MsgBox(4096, "SubKey #" & $i & " under HKLM\Software: ", $var & " - DHCP: " & $dhcp) Next Dabus: of course suggestions are nice, but nicer is to give someone some code so he can work with something, especially if he's just starting. I'm not saying to make all his work for him but when i started i prefered to be given some code instead of just "you can try this" and 0 code My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
_Chris_ Posted September 12, 2006 Author Share Posted September 12, 2006 Thanks guys, this is all briliant. I am new to autoit but i have written some fantastic scripts and love the program. I really apresciate all the help i get on here! The reg way is briliant but is there a way to get it to only look for one network conection, i want it to check the conection used for the remote assistance. This is defined in an ini file and i can get it to read from the file. The program im writing changes the ip address to autoasign by dhcp on startup, this slows it down and isnt necisary if the ip is already auto asigned. Link to comment Share on other sites More sharing options...
MadBoy Posted September 12, 2006 Share Posted September 12, 2006 Well it's hard to say what network connection you are realy looking for .. you should open regedit now and check on your computer what more then just "DHCP ENABLED" can tell you if your connection is the one you're looking for. I would check if the IP is assigned by DHCP and if it matches lets say 192.168.*.* or not. For example if value DhcpIPAddress or DhcpServer server is the one matching yours. That way you could tell if it's interface you're looking for or not. Well you gotta play with it. My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
_Chris_ Posted September 12, 2006 Author Share Posted September 12, 2006 yeah that was my first thought, i checked the registry to see if there way any way to identify the connection, but as it happens, my wireless ip address for work is in the same scope as my wired address at home, cos its a 192.168.1.* addy! Maybe the dos aproach yield an answer... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now