If (@OSVersion <> "WIN_2003") And (@OSVersion <> "WIN_XP") And (@OSVersion <> "WIN_XPe") Then ConsoleWrite("Suported OS version are WinXP and Windows Server 2003 " & @CRLF) Exit 2 EndIf ;checks OS version If ($CmdLine[0] <> 2 ) And ($CmdLine[2]<>"on" Or $CmdLine[2]<>"off") Then ConsoleWrite("expected parameters are : Loca Area Connection Name and on/off switch for ipv4 stack " & @CRLF) Exit 1 EndIf ;check command line arguments Dim $connectionName Dim $switcher $connectionName=$CmdLine[1] $switcher=$CmdLine[2] $networkProperties=$connectionName & " Properties" ;name of network connection properties window $networkStatus=$connectionName & " Status" ;name of network connection status window WinClose($networkProperties) sleep(100) WinClose($networkStatus) sleep(100) WinClose("Network Connections") sleep(100) Run("explorer ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}") ;Run("control ncpa.cpl") ;opens network connections sleep (1500) WinActivate ( "Network Connections") dim $loop_counter $loop_counter=0 While Not WinActive ( "Network Connections" ) $loop_counter+=1 sleep(10) if($loop_counter = 100 ) then ConsoleWrite("Cannot handle Network Connections window " & @CRLF) exit 3 EndIf WEnd $selected_class = ControlGetFocus("[CLASS:CabinetWClass]") ControlFocus ( "[Class:SysListView32]", "", "SysListView321") $b=ControlListView("Network Connections" ,"", "SysListView321","FindItem", $connectionName) $c=ControlListView("Network Connections" ,"", "SysListView321","GetText", 1) ControlListView("Network Connections" ,"", "SysListView321","Select", $b) Send("{ENTER}") sleep (2000) ;opens network connection Send("!p") sleep (2000) ;sends Alt+p and opens network connection properties WinActivate ($networkProperties) $loop_counter=0 While Not WinActivate ($networkProperties) $loop_counter+=1 sleep(10) if($loop_counter = 100 ) then ConsoleWrite("Cannot handle Network Properties window " & @CRLF) exit 4 EndIf WEnd $selected_class2 = ControlGetFocus($networkProperties) $items_count=ControlListView($networkProperties ,"", "SysListView321","GetItemCount") $item_text="" $ipv4_pos=-1 For $i=0 to $items_count-1 Step 1 $item_text=ControlListView($networkProperties ,"", "SysListView321","GetText", $i) $compare=StringCompare ( "Internet Protocol (TCP/IP)", $item_text ) if $compare = 0 then $ipv4_pos=$i ExitLoop EndIf Next ;sarch for TCP/IP protocol if exists if $ipv4_pos=-1 Then ConsoleWrite("Cannot find ip4 protocol " & @CRLF) Exit 5 EndIf Send("{PGUP}") sleep(100) for $i=1 to $ipv4_pos step 1 sleep(100) Send("{DOWN}") Next sleep (10) ;select TCP/IP protocol $is_en=ControlCommand($networkProperties, "", "Button4", "IsEnabled", "") ;check if properties button is active.If it is active then TCP/IP protocol is enabled If $switcher="off" and $is_en=1 Then Send("{SPACE}") EndIf If $switcher="on" and $is_en=0 Then Send("{SPACE}") EndIf ;press space to enable/disable protocol if it is neccessary ControlClick ( $networkProperties, "", "Button8") sleep (2000) WinClose($networkStatus) sleep(100) WinClose("Network Connections") sleep(100) ;close all windows