BasicOs Posted August 22, 2006 Share Posted August 22, 2006 (edited) I made a script for managing diferent locations ip settings, if you have something to improve or correct tell without doubt and thinking, you are wellcomeFor windows XP (win 2000 not tested)tunet.au3tunet.txt (storage for several location ip settings)----------For windows 95/98:queip.au3All improvement and changes are wellcome if somebody who wants to join both in one script together with if os..... also Wellcometunet.txttunet.au3queip.au3 Edited August 22, 2006 by BasicOs Autoit.es - Foro Autoit en EspaƱol Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http Link to comment Share on other sites More sharing options...
sandyd Posted August 23, 2006 Share Posted August 23, 2006 Here's one I have done for our company. It allows all users of laptops to be able to move freely between depots withough having to know their ip address. It uses an ini file and this contains the list of depots and ip changes required. All, the users have to do is select the depot they are currently in and the script does the rest. I'm pretty sure it can be improved, as each laptop needs a different ini file, although the only change is the last number in the IP address for each depot. (Suppose we could store that as an environment variable and just read it when required, in fact I think I will do it that way) Notice that it uses the netsh command line to change the ip settings. expandcollapse popup#include <guilist.au3> #include <GUIConstants.au3> $frmMain = GUICreate(" Depot Switcher", 162, 292, 192, 125, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST)) $lstDepot = GUICtrlCreateList("", 8, 8, 145, 279, -1, $WS_EX_CLIENTEDGE) ;Set some variables $IniFileName = 'DepotDetails.ini' ; Get list of Depots $DepotArray = IniReadSectionNames($IniFileName) For $i = 1 To $DepotArray[0] _GUICtrlListAddItem($lstDepot, $DepotArray[$i]) Next GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $lstDepot SwitchDepot(_GUICtrlListGetText($lstDepot,_GUICtrlListSelectedIndex($lstDepot))) Case Else ;;;;;;; EndSelect WEnd Exit Func SwitchDepot($aDepot) SplashTextOn('','Switching Depot, Please wait ...',300,20) RunAsSet('administrator',@ComputerName,'PasswordHidden') $DepotIPType = IniRead($IniFileName, $aDepot, "Type", "Not Found") If $DepotIPType = 'DHCP' Then $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip set address "Local Area Connection" dhcp','c:\',@SW_HIDE) Else $ipno = IniRead($IniFileName,'IP','Number','') $ipaddr = IniRead($IniFileName,$aDepot,'ipaddr','') $subnetmask = IniRead($IniFileName,$aDepot,'subnetmask','') $gateway = IniRead($IniFileName,$aDepot,'gateway','') $metric = IniRead($IniFileName,$aDepot,'metric','') $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip set address "Local Area Connection" static ' & $ipaddr & ' ' & $subnetmask & ' ' & $gateway & ' ' & $metric,'c:\',@SW_HIDE) $DnsArray = StringSplit(IniRead($IniFileName,$aDepot,'dns',''),'|') If $DnsArray[0] <> 0 Then For $i = 1 To $DnsArray[0] If $i = 1 Then $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip set dns "Local Area Connection" static ' & $DnsArray[$i] & ' primary','c:\',@SW_HIDE) Else $Result = RunWait(@ComSpec & " /c " & 'netsh interface ip add dns "Local Area Connection" ' & $DnsArray[$i] & ' index=' & $i,'c:\',@SW_HIDE) EndIf Next EndIf EndIf SplashOff() EndFunc and the ini file to configure it: [Perth]Type=DHCP [beauly] Type=DHCP [Killin] Type=DHCP [Corpach] Type=Static ipaddr = 192.168.196.57 subnetmask = 255.255.255.0 gateway = 192.168.196.251 metric = 1 dns = 192.168.10.213|192.168.10.215 [Ardelve - Do NOT Use] Type=Static ipaddr = 192.168.196.57 subnetmask = 255.255.255.0 gateway = 192.168.196.251 metric = 1 dns = 192.168.10.213|192.168.10.215 [inveraray] Type=Static ipaddr = 192.168.195.57 subnetmask = 255.255.255.0 gateway = 192.168.195.251 metric = 1 dns = 192.168.10.213|192.168.10.215 [Kingussie] Type=Static ipaddr = 10.60.100.57 subnetmask = 255.255.255.0 gateway = 10.60.100.251 metric = 1 dns = 192.168.10.200|192.168.10.201 ----[ SandyD ]--- 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