Sign in to follow this  
Followers 0
ZenKensei

Clearing GUIState & Control Swapping

5 posts in this topic

Group,

Currently working on a GUI script to help create Cisco switch templates for our Enterprise as part of a large company merger. The script basically allows the user to input basic information about the switch, including name, ip address, etc. as well as VLAN information for each port and then creates a text file named after the switch that can be 'cut & pasted' into the switch via either Hyperterminal or Telnet.

I have 3 relatively small problems:

1) I want to be able to 'turn off' or 'block' one control or selection if another one is selected. Specifically, in this script, in the Port1 and Port24 grouping, if the 'Trunking Enabled' checkbox is cleared I want the Combo dropdown boxes to be 'active' but if the 'Trunking Enabled' checkbox is checked I want the Combo dropdown box to be either hidden, greyed out, or otherwise inaccessable.

2) How to show to the user a 'default' selection in the combo boxes for ports 2 - 23 (i.e. I would like the user to see 'VLAN 40' in the box so that if they don't select something different that will be the selected default value) and for VLAN 40 to be the default entry for that control. I have tried a few controls but nothing seems to be visible in all of those boxes when the script runs.

3) I want to be able 'clear' the form after I create the text file template so I can create a additional templates insuring that the settings are back to a 'defaults'.

If anyone has time to take a quick look and make some suggestions I would really appreciate it...

See the code below:

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 642, 535, 184, 112)
$Group1 = GUICtrlCreateGroup("Switch Info", 16, 8, 257, 145)
GUICtrlCreateLabel("Switch Name:", 24, 24, 70, 17)
GUICtrlSetTip(-1, "Switch Network Name")
$ASwitchName = GUICtrlCreateInput("", 96, 24, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. MC002XNS2901")
GUICtrlCreateLabel("Switch IP:", 24, 48, 52, 17)
GUICtrlSetTip(-1, "Switch IP Address")
$ASwitchIP = GUICtrlCreateInput("", 96, 48, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "11.54.333.444")
GUICtrlCreateLabel("Switch GWY:", 24, 72, 68, 17)
GUICtrlSetTip(-1, "Switch Default Gateway")
$ASwitchGWY = GUICtrlCreateInput("", 96, 72, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 11.54.111.254")
GUICtrlCreateLabel("Switch Mask:", 24, 96, 68, 17)
GUICtrlSetTip(-1, "Switch Subnet Mask")
$ASwitchMask = GUICtrlCreateInput("255.255.254.0", 96, 96, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 255.255.254.0")
GUICtrlCreateLabel("Switch Loc:", 24, 120, 60, 17)
GUICtrlSetTip(-1, "Switch Location")
$ASwitchLoc = GUICtrlCreateInput("1FL MDF Rack 1 Position 1", 96, 120, 161, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 1FL - MDF Rack 1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "General Switch Info")
$Group2 = GUICtrlCreateGroup("Port 1 Configuration", 288, 8, 161, 145)
$ATrunking1 = GUICtrlCreateCheckbox("Trunking Enabled", 304, 32, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, " FA0/1 Trunking On")
$APortFast1 = GUICtrlCreateCheckbox("PortFast Enabled", 304, 56, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/1 PortFast Spanning")
$APort1 = GUICtrlCreateCombo("", 304, 120, 113, 21)
GUICtrlSetData(-1, "TRUNK|VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "VLAN Access Mode")
$ASpeed1 = GUICtrlCreateCheckbox("100Mb / Full Duplex", 304, 80, 129, 17)
GUICtrlSetTip(-1, "Set Speed to 100mb / Full Duplex")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "FA0/1 Config")
$Group3 = GUICtrlCreateGroup("Port 24 Configuration", 464, 8, 161, 145)
$ATrunking24 = GUICtrlCreateCheckbox("Trunking Enabled", 480, 32, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/24 Trunking On")
$APortFast24 = GUICtrlCreateCheckbox("PortFast Enabled", 480, 56, 105, 17)
; GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/24 PortFast Spanning")
$APort24 = GUICtrlCreateCombo("", 480, 120, 113, 21)
GUICtrlSetData(-1, "TRUNK|VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "VLAN Access Mode")
$ASpeed24 = GUICtrlCreateCheckbox("100Mb / Full Duplex", 480, 80, 129, 17)
GUICtrlSetTip(-1, "Set Speed to 100mb / Full Duplex")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "Port 24 Uplink Config")
$Group4 = GUICtrlCreateGroup("Standard Port Configuration", 16, 232, 609, 233)
GUICtrlCreateLabel("Port FA0/2", 32, 256, 56, 17)
GUICtrlSetTip(-1, "FA0/2 VLAN Access")
$APort2 = GUICtrlCreateCombo("", 32, 272, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 2 VLAN Access")
GUICtrlCreateLabel("Port FA0/3", 32, 304, 56, 17)
GUICtrlSetTip(-1, "FA0/3 VLAN Access")
$APort3 = GUICtrlCreateCombo("", 32, 320, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 3 VLAN Access")
GUICtrlCreateLabel("Port FA0/4", 32, 352, 56, 17)
GUICtrlSetTip(-1, "FA0/4 VLAN Access")
$APort4 = GUICtrlCreateCombo("", 32, 368, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 4 VLAN Access")
GUICtrlCreateLabel("Port FA0/5", 32, 400, 56, 17)
GUICtrlSetTip(-1, "FA0/5 VLAN Access")
$APort5 = GUICtrlCreateCombo("", 32, 416, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 5 VLAN Access")
GUICtrlCreateLabel("Port FA0/6", 128, 256, 56, 17)
GUICtrlSetTip(-1, "FA0/6 VLAN Access")
$APort6 = GUICtrlCreateCombo("", 128, 272, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 6 VLAN Access")
GUICtrlCreateLabel("Port FA0/7", 128, 304, 56, 17)
GUICtrlSetTip(-1, "FA0/7 VLAN Access")
$APort7 = GUICtrlCreateCombo("", 128, 320, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 7 VLAN Access")
GUICtrlCreateLabel("Port FA0/8", 128, 352, 56, 17)
GUICtrlSetTip(-1, "FA0/8 VLAN Access")
$APort8 = GUICtrlCreateCombo("", 128, 368, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 8 VLAN Access")
GUICtrlCreateLabel("Port FA0/9", 128, 400, 56, 17)
GUICtrlSetTip(-1, "FA0/9 VLAN Access")
$APort9 = GUICtrlCreateCombo("", 128, 416, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 9 VLAN Access")
GUICtrlCreateLabel("Port FA0/10", 224, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/10 VLAN Access")
$APort10 = GUICtrlCreateCombo("", 224, 272, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 10 VLAN Access")
GUICtrlCreateLabel("Port FA0/11", 224, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/11 VLAN Access")
$APort11 = GUICtrlCreateCombo("", 224, 320, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlCreateLabel("Port FA0/12", 224, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/12 VLAN Access")
$APort12 = GUICtrlCreateCombo("", 224, 368, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlCreateLabel("Port FA0/13", 224, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/13 VLAN Access")
$APort13 = GUICtrlCreateCombo("", 224, 416, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlCreateLabel("Port FA0/14", 328, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/14 VLAN Access")
$APort14 = GUICtrlCreateCombo("", 328, 272, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 14 VLAN Access")
GUICtrlCreateLabel("Port FA0/15", 328, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/15VLAN Access")
$APort15 = GUICtrlCreateCombo("", 328, 320, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 15 VLAN Access")
GUICtrlCreateLabel("Port FA0/16", 328, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/16 VLAN Access")
$APort16 = GUICtrlCreateCombo("", 328, 368, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 16 VLAN Access")
GUICtrlCreateLabel("Port FA0/17", 328, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/17 VLAN Access")
$APort17 = GUICtrlCreateCombo("", 328, 416, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 17 VLAN Access")
GUICtrlCreateLabel("Port FA0/18", 432, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/18 VLAN Access")
$APort18 = GUICtrlCreateCombo("", 432, 272, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 18 VLAN Access")
GUICtrlCreateLabel("Port FA0/19", 432, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/19 VLAN Access")
$APort19 = GUICtrlCreateCombo("", 432, 320, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 19 VLAN Access")
GUICtrlCreateLabel("Port FA0/20", 432, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/20 VLAN Access")
$APort20 = GUICtrlCreateCombo("", 432, 368, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 20 VLAN Access")
GUICtrlCreateLabel("Port FA0/21", 432, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/21 VLAN Access")
$APort21 = GUICtrlCreateCombo("", 432, 416, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 21 VLAN Access")
GUICtrlCreateLabel("Port FA0/22", 528, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/22 VLAN Access")
$APort22 = GUICtrlCreateCombo("", 528, 272, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 22 VLAN Access")
GUICtrlCreateLabel("Port FA0/23", 528, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/23 VLAN Access")
$APort23 = GUICtrlCreateCombo("", 528, 320, 73, 21)
GUICtrlSetData(-1, "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40")
GUICtrlSetTip(-1, "Port 23 VLAN Access")
GUICtrlCreateLabel("", 528, 352, 4, 4)
GUICtrlCreateLabel("All ports are auto", 528, 352, 83, 17)
GUICtrlCreateLabel("speed and duplex.", 528, 368, 91, 17)
GUICtrlCreateLabel("All ports are", 528, 384, 59, 17)
GUICtrlCreateLabel("VLAN 40 by", 528, 400, 61, 17)
GUICtrlCreateLabel("default.", 528, 416, 39, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "FA0/2 - FA0/23 Configs")
$Button1 = GUICtrlCreateButton("Write Config File", 136, 480, 97, 25)
GUICtrlSetTip(-1, "Create config file")
$Button2 = GUICtrlCreateButton("Clear Form", 272, 480, 97, 25)
GUICtrlSetTip(-1, "Clear the form")
$Button3 = GUICtrlCreateButton("Exit", 408, 480, 81, 25)
GUICtrlSetTip(-1, "Exit Application")
$Group5 = GUICtrlCreateGroup("VTP Information", 16, 160, 257, 65)
GUICtrlCreateLabel("VTP Domain:", 24, 176, 67, 17)
GUICtrlSetTip(-1, "VTP Domain Name")
$AVTPDomain = GUICtrlCreateInput("", 104, 176, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. FLO700X")
GUICtrlCreateLabel("VTP Password:", 24, 200, 77, 17)
GUICtrlSetTip(-1, "VTP Server Password")
$AVTPPassword = GUICtrlCreateInput("", 104, 200, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. FLO700X")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "VTP Server Info")

; GUISetState(@SW_SHOW)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_Close
   $msg = GUIGetMsg()
   Select
      Case $msg = ($Button1)
         _WriteConfig(GUICtrlRead($ASwitchName))
      Case $msg = ($Button3)
         MsgBox(0, "EXIT", "Exiting Cisco Config", 2)
         Exit
   EndSelect
WEnd
Exit

Func _WriteConfig($ASwitchName)
   $SwitchName = $ASwitchName
   $IPAddress = (GUICtrlRead($ASwitchIP))
   $Gateway = (GUICtrlRead($ASwitchGWY))
   $SubnetMask = (GUICtrlRead($ASwitchMask))
   $VTPDomain = (GUICtrlRead($AVTPDomain))
   $VTPPassword = (GUICtrlRead($AVTPPassword))
   $Trunking1 = (GUICtrlRead($ATrunking1))
   $PortFast1 = (GUICtrlRead($APortFast1))
   $Speed1 = (GUICtrlRead($ASpeed1))
   $Port1 = (GUICtrlRead($APort1))
   $Trunking24 = (GUICtrlRead($ATrunking24))
   $PortFast24 = (GUICtrlRead($APortFast24))
   $Speed24 = (GUICtrlRead($ASpeed24))
   $Port24 = (GUICtrlRead($APort24))
   
   
   If $SwitchName <> "" And $IPAddress <> "" And $Gateway <> "" Then
      
      $Port1 = (GUICtrlRead($APort1))
      If $Port1 = "" Then $Port1 = ("TRUNK")
      $Trunking1 = (GUICtrlRead($ATrunking1))
      $PortFast1 = (GUICtrlRead($APortFast1))
      $Speed1 = (GUICtrlRead($ASpeed1))
      $Port2 = (GUICtrlRead($APort2))
      If $Port2 = "" Then $Port2 = ("VLAN 40")
      $Port3 = (GUICtrlRead($APort3))
      If $Port3 = "" Then $Port3 = ("VLAN 40")
      $Port4 = (GUICtrlRead($APort4))
      If $Port4 = "" Then $Port4 = ("VLAN 40")
      $Port5 = (GUICtrlRead($APort5))
      If $Port5 = "" Then $Port5 = ("VLAN 40")
      $Port6 = (GUICtrlRead($APort6))
      If $Port6 = "" Then $Port6 = ("VLAN 40")
      $Port7 = (GUICtrlRead($APort7))
      If $Port7 = "" Then $Port7 = ("VLAN 40")
      $Port8 = (GUICtrlRead($APort8))
      If $Port8 = "" Then $Port8 = ("VLAN 40")
      $Port9 = (GUICtrlRead($APort9))
      If $Port9 = "" Then $Port9 = ("VLAN 40")
      $Port10 = (GUICtrlRead($APort10))
      If $Port10 = "" Then $Port10 = ("VLAN 40")
      $Port11 = (GUICtrlRead($APort11))
      If $Port11 = "" Then $Port11 = ("VLAN 40")
      $Port12 = (GUICtrlRead($APort12))
      If $Port12 = "" Then $Port12 = ("VLAN 40")
      $Port13 = (GUICtrlRead($APort13))
      If $Port13 = "" Then $Port13 = ("VLAN 40")
      $Port14 = (GUICtrlRead($APort14))
      If $Port14 = "" Then $Port14 = ("VLAN 40")
      $Port15 = (GUICtrlRead($APort15))
      If $Port15 = "" Then $Port15 = ("VLAN 40")
      $Port16 = (GUICtrlRead($APort16))
      If $Port16 = "" Then $Port16 = ("VLAN 40")
      $Port17 = (GUICtrlRead($APort17))
      If $Port17 = "" Then $Port17 = ("VLAN 40")
      $Port18 = (GUICtrlRead($APort18))
      If $Port18 = "" Then $Port18 = ("VLAN 40")
      $Port19 = (GUICtrlRead($APort19))
      If $Port19 = "" Then $Port19 = ("VLAN 40")
      $Port20 = (GUICtrlRead($APort20))
      If $Port20 = "" Then $Port20 = ("VLAN 40")
      $Port21 = (GUICtrlRead($APort21))
      If $Port21 = "" Then $Port21 = ("VLAN 40")
      $Port22 = (GUICtrlRead($APort22))
      If $Port22 = "" Then $Port22 = ("VLAN 40")
      $Port23 = (GUICtrlRead($APort23))
      If $Port23 = "" Then $Port23 = ("VLAN 40")
      $Port24 = (GUICtrlRead($APort24))
      If $Port24 = "" Then $Port24 = ("TRUNK")
      $Trunking24 = (GUICtrlRead($ATrunking24))
      $PortFast24 = (GUICtrlRead($APortFast24))
      $Speed24 = (GUICtrlRead($ASpeed24))
            
      MsgBox(4096, "Switch Name", "Switch Network Name is: " & $SwitchName, 2)
      MsgBox(4096, "IP Address", "Switch Gateway IP Address is: " & $IPAddress, 2)
     ; MsgBox(4096, "Defualt Gateway", "Switch Gateway IP Address is: " & $Gateway, 2)
     ; MsgBox(4096, "Subnet Mask", "Switch Subnet Mask is: " & $SubnetMask, 2)
     ; MsgBox(4096, "VTP Domain", "Switch VTP Domain is: " & $VTPDomain, 2)
     ; MsgBox(4096, "VTP Password", "Switch VTP Password is: " & $VTPPassword, 2)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Trunking is: " & $Trunking1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Spanning is: " & $PortFast1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Speed is: " & $Speed1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 VLAN is: " & $Port1)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Trunking is: " & $Trunking24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Spanning is: " & $PortFast24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Speed is: " & $Speed24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 VLAN is: " & $Port24)
     
      If FileExists(@ScriptDir & "\" & $SwitchName & ".txt") Then FileDelete(@ScriptDir & "\" & $SwitchName & ".txt")
      $SwitchFile = FileOpen(@ScriptDir & "\" & $SwitchName & ".txt", 1)
      
     ; Check if file opened for writing OK
      If $SwitchFile = -1 Then
         MsgBox(0, "Error", "Unable to open logfile.")
         Exit
      EndIf
      
     ; The following 4 lines write general switch information to the config file.
     ; Rem these lines out or do not 'cut' them to be pasted.
      FileWrite($SwitchFile, "Switch Name: " & $SwitchName & @CRLF)
      FileWrite($SwitchFile, "IP Address: " & $IPAddress & @CRLF)
      FileWrite($SwitchFile, "Gateway: " & $Gateway & @CRLF)
      FileWrite($SwitchFile, "Subnet Mask: " & $SubnetMask & @CRLF)
      FileWrite($SwitchFile, @CRLF)
      
     ; The following section is the 'header section of the switch config.
     ; This information is always the same for configs created with this application.
      FileWrite($SwitchFile, "vlan database" & @CRLF)
      FileWrite($SwitchFile, "vtp mode client" & @CRLF)
      FileWrite($SwitchFile, "VTP DOMAIN " & $VTPDomain & @CRLF)
      FileWrite($SwitchFile, "vtp V2-MODE" & @CRLF)
      FileWrite($SwitchFile, "VTP PASSWORD " & $VTPPassword & @CRLF)
      FileWrite($SwitchFile, "EXIT" & @CRLF)
      
     ; Downlink Port 1 - Default Trunk Port For Switch to Switch Connection
     ; This port is used for connection to 'lower' switches (i.e. 2900's, 1900's, etc)
      If $Port1 = ("Trunk") Then 
      FileWrite($SwitchFile, "interface FastEthernet0/1" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT TRUNK ENCAP DOT1Q" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT MODE TRUNK" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      Else
      FileWrite($SwitchFile, "interface FastEthernet0/1" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port1  & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
  EndIf
      If $Speed1 = 1 Then
          FileWrite($SwitchFile, "speed 100" & @CRLF)
          FileWrite($SwitchFile, "duplex full" & @CRLF)
          EndIf
      
     ; The following section starts the actual Port config for FA0/2 - FA0/23
      FileWrite($SwitchFile, "interface FastEthernet0/2" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port2 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/3" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port3 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/4" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port4 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/5" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port5 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/6" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port6 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/7" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port7 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/8" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port8 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/9" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port9 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/10" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port10 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/11" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port11 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/12" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port12 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/13" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port13 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/14" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port14 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/15" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port15 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/16" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port16 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/17" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port17 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/18" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port18 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/19" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port19 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/20" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port20 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/21" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port21 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/22" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port22 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/23" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port23 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
     ; UpLink Port 24 - Default Trunk Port For Switch to Switch Connection
     ; This port is used for connection to 'higher' switches (i.e. 3560's, etc)
      If $Port24 = ("Trunk") Then 
      FileWrite($SwitchFile, "interface FastEthernet0/24" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT TRUNK ENCAP DOT1Q" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT MODE TRUNK" & @CRLF)
      Else
      FileWrite($SwitchFile, "interface FastEthernet0/24" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port24  & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
  EndIf
      If $Speed24 = 1 Then
          FileWrite($SwitchFile, "speed 100" & @CRLF)
          FileWrite($SwitchFile, "duplex full" & @CRLF)
          EndIf
      
      FileWrite($SwitchFile, "" & @CRLF)
      FileWrite($SwitchFile, "" & @CRLF)
     ; The following section completes the switch config file.
      FileWrite($SwitchFile, "interface Vlan1" & @CRLF)
      FileWrite($SwitchFile, "no ip address" & @CRLF)
      FileWrite($SwitchFile, "no ip route-cache" & @CRLF)
      FileWrite($SwitchFile, "shutdown" & @CRLF)
      FileWrite($SwitchFile, "!" & @CRLF)
      FileWrite($SwitchFile, "INTERFACE VLAN 10" & @CRLF)
      FileWrite($SwitchFile, "ip address " & $IPAddress & " " & $SubnetMask & @CRLF)
      FileWrite($SwitchFile, "" & @CRLF)
      FileWrite($SwitchFile, "no ip route-cache" & @CRLF)
      FileWrite($SwitchFile, "!" & @CRLF)
      FileWrite($SwitchFile, "IP DEFAULT-GATEWAY " & $Gateway & @CRLF)
      FileWrite($SwitchFile, "Managed Hostname: " & $SwitchName & @CRLF)
            
      FileClose($SwitchFile)
      
      
   ElseIf $SwitchName = "" Or $IPAddress = "" Or $Gateway = "" Then
      MsgBox(4096, "Missing Information", "You must first enter Switch Name, IP Address & Default Gateway", 5)
   EndIf
EndFunc  ;==>_WriteConfig

I'm sure it could be shorter and cleaner, but it works...

As always, thanks in advance for any advice or help!

ZenKensei

Share this post


Link to post
Share on other sites



Hi ZenKensei,

Did you mean something like this ?

#include <GUIConstants.au3>

Global Const $defaultVlan = "VLAN 40"
Global Const $vlanList = "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40"

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 642, 535, 184, 112)
$Group1 = GUICtrlCreateGroup("Switch Info", 16, 8, 257, 145)
GUICtrlCreateLabel("Switch Name:", 24, 24, 70, 17)
GUICtrlSetTip(-1, "Switch Network Name")
$ASwitchName = GUICtrlCreateInput("", 96, 24, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. MC002XNS2901")
GUICtrlCreateLabel("Switch IP:", 24, 48, 52, 17)
GUICtrlSetTip(-1, "Switch IP Address")
$ASwitchIP = GUICtrlCreateInput("", 96, 48, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "11.54.333.444")
GUICtrlCreateLabel("Switch GWY:", 24, 72, 68, 17)
GUICtrlSetTip(-1, "Switch Default Gateway")
$ASwitchGWY = GUICtrlCreateInput("", 96, 72, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 11.54.111.254")
GUICtrlCreateLabel("Switch Mask:", 24, 96, 68, 17)
GUICtrlSetTip(-1, "Switch Subnet Mask")
$ASwitchMask = GUICtrlCreateInput("255.255.254.0", 96, 96, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 255.255.254.0")
GUICtrlCreateLabel("Switch Loc:", 24, 120, 60, 17)
GUICtrlSetTip(-1, "Switch Location")
$ASwitchLoc = GUICtrlCreateInput("1FL MDF Rack 1 Position 1", 96, 120, 161, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 1FL - MDF Rack 1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "General Switch Info")

$Group2 = GUICtrlCreateGroup("Port 1 Configuration", 288, 8, 161, 145)
$ATrunking1 = GUICtrlCreateCheckbox("Trunking Enabled", 304, 32, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, " FA0/1 Trunking On")
$APortFast1 = GUICtrlCreateCheckbox("PortFast Enabled", 304, 56, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/1 PortFast Spanning")
$APort1 = GUICtrlCreateCombo("", 304, 120, 113, 21)
GUICtrlSetData(-1, "TRUNK|VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40","TRUNK")
GuiCtrlSetState($APort1,$GUI_DISABLE)
GUICtrlSetTip(-1, "VLAN Access Mode")
$ASpeed1 = GUICtrlCreateCheckbox("100Mb / Full Duplex", 304, 80, 129, 17)
GUICtrlSetTip(-1, "Set Speed to 100mb / Full Duplex")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "FA0/1 Config")
$Group3 = GUICtrlCreateGroup("Port 24 Configuration", 464, 8, 161, 145)
$ATrunking24 = GUICtrlCreateCheckbox("Trunking Enabled", 480, 32, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/24 Trunking On")
$APortFast24 = GUICtrlCreateCheckbox("PortFast Enabled", 480, 56, 105, 17)
; GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/24 PortFast Spanning")
$APort24 = GUICtrlCreateCombo("", 480, 120, 113, 21)
GUICtrlSetData(-1, "TRUNK|VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40","TRUNK")
GUICtrlSetTip(-1, "VLAN Access Mode")
GuiCtrlSetState($APort24,$GUI_DISABLE)
$ASpeed24 = GUICtrlCreateCheckbox("100Mb / Full Duplex", 480, 80, 129, 17)
GUICtrlSetTip(-1, "Set Speed to 100mb / Full Duplex")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "Port 24 Uplink Config")

$Group4 = GUICtrlCreateGroup("Standard Port Configuration", 16, 232, 609, 233)
GUICtrlCreateLabel("Port FA0/2", 32, 256, 56, 17)
GUICtrlSetTip(-1, "FA0/2 VLAN Access")
$APort2 = GUICtrlCreateCombo("", 32, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 2 VLAN Access")
GUICtrlCreateLabel("Port FA0/3", 32, 304, 56, 17)
GUICtrlSetTip(-1, "FA0/3 VLAN Access")
$APort3 = GUICtrlCreateCombo("", 32, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 3 VLAN Access")
GUICtrlCreateLabel("Port FA0/4", 32, 352, 56, 17)
GUICtrlSetTip(-1, "FA0/4 VLAN Access")
$APort4 = GUICtrlCreateCombo("", 32, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 4 VLAN Access")
GUICtrlCreateLabel("Port FA0/5", 32, 400, 56, 17)
GUICtrlSetTip(-1, "FA0/5 VLAN Access")
$APort5 = GUICtrlCreateCombo("", 32, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 5 VLAN Access")
GUICtrlCreateLabel("Port FA0/6", 128, 256, 56, 17)
GUICtrlSetTip(-1, "FA0/6 VLAN Access")
$APort6 = GUICtrlCreateCombo("", 128, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 6 VLAN Access")
GUICtrlCreateLabel("Port FA0/7", 128, 304, 56, 17)
GUICtrlSetTip(-1, "FA0/7 VLAN Access")
$APort7 = GUICtrlCreateCombo("", 128, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 7 VLAN Access")
GUICtrlCreateLabel("Port FA0/8", 128, 352, 56, 17)
GUICtrlSetTip(-1, "FA0/8 VLAN Access")
$APort8 = GUICtrlCreateCombo("", 128, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 8 VLAN Access")
GUICtrlCreateLabel("Port FA0/9", 128, 400, 56, 17)
GUICtrlSetTip(-1, "FA0/9 VLAN Access")
$APort9 = GUICtrlCreateCombo("", 128, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 9 VLAN Access")
GUICtrlCreateLabel("Port FA0/10", 224, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/10 VLAN Access")
$APort10 = GUICtrlCreateCombo("", 224, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 10 VLAN Access")
GUICtrlCreateLabel("Port FA0/11", 224, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/11 VLAN Access")
$APort11 = GUICtrlCreateCombo("", 224, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlCreateLabel("Port FA0/12", 224, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/12 VLAN Access")
$APort12 = GUICtrlCreateCombo("", 224, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlCreateLabel("Port FA0/13", 224, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/13 VLAN Access")
$APort13 = GUICtrlCreateCombo("", 224, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlCreateLabel("Port FA0/14", 328, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/14 VLAN Access")
$APort14 = GUICtrlCreateCombo("", 328, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 14 VLAN Access")
GUICtrlCreateLabel("Port FA0/15", 328, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/15VLAN Access")
$APort15 = GUICtrlCreateCombo("", 328, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 15 VLAN Access")
GUICtrlCreateLabel("Port FA0/16", 328, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/16 VLAN Access")
$APort16 = GUICtrlCreateCombo("", 328, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 16 VLAN Access")
GUICtrlCreateLabel("Port FA0/17", 328, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/17 VLAN Access")
$APort17 = GUICtrlCreateCombo("", 328, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 17 VLAN Access")
GUICtrlCreateLabel("Port FA0/18", 432, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/18 VLAN Access")
$APort18 = GUICtrlCreateCombo("", 432, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 18 VLAN Access")
GUICtrlCreateLabel("Port FA0/19", 432, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/19 VLAN Access")
$APort19 = GUICtrlCreateCombo("", 432, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 19 VLAN Access")
GUICtrlCreateLabel("Port FA0/20", 432, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/20 VLAN Access")
$APort20 = GUICtrlCreateCombo("", 432, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 20 VLAN Access")
GUICtrlCreateLabel("Port FA0/21", 432, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/21 VLAN Access")
$APort21 = GUICtrlCreateCombo("", 432, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 21 VLAN Access")
GUICtrlCreateLabel("Port FA0/22", 528, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/22 VLAN Access")
$APort22 = GUICtrlCreateCombo("", 528, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 22 VLAN Access")
GUICtrlCreateLabel("Port FA0/23", 528, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/23 VLAN Access")
$APort23 = GUICtrlCreateCombo("", 528, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 23 VLAN Access")
GUICtrlCreateLabel("", 528, 352, 4, 4)
GUICtrlCreateLabel("All ports are auto", 528, 352, 83, 17)
GUICtrlCreateLabel("speed and duplex.", 528, 368, 91, 17)
GUICtrlCreateLabel("All ports are", 528, 384, 59, 17)
GUICtrlCreateLabel("VLAN 40 by", 528, 400, 61, 17)
GUICtrlCreateLabel("default.", 528, 416, 39, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "FA0/2 - FA0/23 Configs")
$Button1 = GUICtrlCreateButton("Write Config File", 136, 480, 97, 25)
GUICtrlSetTip(-1, "Create config file")
$Button2 = GUICtrlCreateButton("Clear Form", 272, 480, 97, 25)
GUICtrlSetTip(-1, "Clear the form")
$Button3 = GUICtrlCreateButton("Exit", 408, 480, 81, 25)
GUICtrlSetTip(-1, "Exit Application")
$Group5 = GUICtrlCreateGroup("VTP Information", 16, 160, 257, 65)
GUICtrlCreateLabel("VTP Domain:", 24, 176, 67, 17)
GUICtrlSetTip(-1, "VTP Domain Name")
$AVTPDomain = GUICtrlCreateInput("", 104, 176, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. FLO700X")
GUICtrlCreateLabel("VTP Password:", 24, 200, 77, 17)
GUICtrlSetTip(-1, "VTP Server Password")
$AVTPPassword = GUICtrlCreateInput("", 104, 200, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. FLO700X")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "VTP Server Info")

; GUISetState(@SW_SHOW)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_Close
   $msg = GUIGetMsg()
   Select
      Case $msg == ($Button1)
         _WriteConfig(GUICtrlRead($ASwitchName))
         
      Case $msg == ($Button2)
          _clearForm()
          
      Case $msg == $ATrunking1
    If GuiCtrlRead($ATrunking1) == $GUI_CHECKED Then
        GuiCtrlSetData($APort1, "TRUNK|" & $vlanList,"TRUNK")
        GuiCtrlSetState($APort1,$GUI_DISABLE)
    Else
        GuiCtrlSetData($APort1,"TRUNK|" & $vlanList,$defaultVlan)
        GuiCtrlSetState($APort1,$GUI_ENABLE)    
    EndIf

      Case $msg == $ATrunking24
    If GuiCtrlRead($ATrunking24) == $GUI_CHECKED Then
        GuiCtrlSetData($APort24, "TRUNK|" & $vlanList,"TRUNK")
        GuiCtrlSetState($APort24,$GUI_DISABLE)
    Else
        GuiCtrlSetData($APort24,"TRUNK|" & $vlanList,$defaultVlan)
        GuiCtrlSetState($APort24,$GUI_ENABLE)   
    EndIf

      Case $msg == ($Button3)
         MsgBox(0, "EXIT", "Exiting Cisco Config", 2)
         Exit
   EndSelect
WEnd
Exit

; clear (at least partially the display)
Func _clearForm()
; clear id infos
    GuiCtrlSetData($ASwitchName ,"")
    GuiCtrlSetData($ASwitchIP   ,"")
    GuiCtrlSetData($ASwitchGWY  ,"")
    GuiCtrlSetData($ASwitchMask ,"255.255.254.0")
    GuiCtrlSetData($ASwitchLoc  ,"1FL MDF Rack 1 Position 1")
; clear ports 2-23
For $i= 2 To 23
    GuiCtrlSetData(Eval("APort" & $i),$vlanList,$defaultVlan)
Next
; clear ports 1; 24
    GuiCtrlSetData($APort1, "TRUNK|" & $vlanList,"TRUNK")
    GuiCtrlSetState($APort1,$GUI_DISABLE)
    GuiCtrlSetData($APort24, "TRUNK|" & $vlanList,"TRUNK")
    GuiCtrlSetState($APort24,$GUI_DISABLE)

; clear vtp infos
    GuiCtrlSetData($AVTPDomain  ,"")
    GuiCtrlSetData($AVTPPassword    ,"")
EndFunc

Func _WriteConfig($ASwitchName)
   $SwitchName = $ASwitchName
   $IPAddress = (GUICtrlRead($ASwitchIP))
   $Gateway = (GUICtrlRead($ASwitchGWY))
   $SubnetMask = (GUICtrlRead($ASwitchMask))
   $VTPDomain = (GUICtrlRead($AVTPDomain))
   $VTPPassword = (GUICtrlRead($AVTPPassword))
   $Trunking1 = (GUICtrlRead($ATrunking1))
   $PortFast1 = (GUICtrlRead($APortFast1))
   $Speed1 = (GUICtrlRead($ASpeed1))
   $Port1 = (GUICtrlRead($APort1))
   $Trunking24 = (GUICtrlRead($ATrunking24))
   $PortFast24 = (GUICtrlRead($APortFast24))
   $Speed24 = (GUICtrlRead($ASpeed24))
   $Port24 = (GUICtrlRead($APort24))
   
   
   If $SwitchName <> "" And $IPAddress <> "" And $Gateway <> "" Then
      
      $Port1 = (GUICtrlRead($APort1))
      If $Port1 = "" Then $Port1 = ("TRUNK")
      $Trunking1 = (GUICtrlRead($ATrunking1))
      $PortFast1 = (GUICtrlRead($APortFast1))
      $Speed1 = (GUICtrlRead($ASpeed1))
      $Port2 = (GUICtrlRead($APort2))
      If $Port2 = "" Then $Port2 = ("VLAN 40")
      $Port3 = (GUICtrlRead($APort3))
      If $Port3 = "" Then $Port3 = ("VLAN 40")
      $Port4 = (GUICtrlRead($APort4))
      If $Port4 = "" Then $Port4 = ("VLAN 40")
      $Port5 = (GUICtrlRead($APort5))
      If $Port5 = "" Then $Port5 = ("VLAN 40")
      $Port6 = (GUICtrlRead($APort6))
      If $Port6 = "" Then $Port6 = ("VLAN 40")
      $Port7 = (GUICtrlRead($APort7))
      If $Port7 = "" Then $Port7 = ("VLAN 40")
      $Port8 = (GUICtrlRead($APort8))
      If $Port8 = "" Then $Port8 = ("VLAN 40")
      $Port9 = (GUICtrlRead($APort9))
      If $Port9 = "" Then $Port9 = ("VLAN 40")
      $Port10 = (GUICtrlRead($APort10))
      If $Port10 = "" Then $Port10 = ("VLAN 40")
      $Port11 = (GUICtrlRead($APort11))
      If $Port11 = "" Then $Port11 = ("VLAN 40")
      $Port12 = (GUICtrlRead($APort12))
      If $Port12 = "" Then $Port12 = ("VLAN 40")
      $Port13 = (GUICtrlRead($APort13))
      If $Port13 = "" Then $Port13 = ("VLAN 40")
      $Port14 = (GUICtrlRead($APort14))
      If $Port14 = "" Then $Port14 = ("VLAN 40")
      $Port15 = (GUICtrlRead($APort15))
      If $Port15 = "" Then $Port15 = ("VLAN 40")
      $Port16 = (GUICtrlRead($APort16))
      If $Port16 = "" Then $Port16 = ("VLAN 40")
      $Port17 = (GUICtrlRead($APort17))
      If $Port17 = "" Then $Port17 = ("VLAN 40")
      $Port18 = (GUICtrlRead($APort18))
      If $Port18 = "" Then $Port18 = ("VLAN 40")
      $Port19 = (GUICtrlRead($APort19))
      If $Port19 = "" Then $Port19 = ("VLAN 40")
      $Port20 = (GUICtrlRead($APort20))
      If $Port20 = "" Then $Port20 = ("VLAN 40")
      $Port21 = (GUICtrlRead($APort21))
      If $Port21 = "" Then $Port21 = ("VLAN 40")
      $Port22 = (GUICtrlRead($APort22))
      If $Port22 = "" Then $Port22 = ("VLAN 40")
      $Port23 = (GUICtrlRead($APort23))
      If $Port23 = "" Then $Port23 = ("VLAN 40")
      $Port24 = (GUICtrlRead($APort24))
      If $Port24 = "" Then $Port24 = ("TRUNK")
      $Trunking24 = (GUICtrlRead($ATrunking24))
      $PortFast24 = (GUICtrlRead($APortFast24))
      $Speed24 = (GUICtrlRead($ASpeed24))
            
      MsgBox(4096, "Switch Name", "Switch Network Name is: " & $SwitchName, 2)
      MsgBox(4096, "IP Address", "Switch Gateway IP Address is: " & $IPAddress, 2)
    ; MsgBox(4096, "Defualt Gateway", "Switch Gateway IP Address is: " & $Gateway, 2)
    ; MsgBox(4096, "Subnet Mask", "Switch Subnet Mask is: " & $SubnetMask, 2)
    ; MsgBox(4096, "VTP Domain", "Switch VTP Domain is: " & $VTPDomain, 2)
    ; MsgBox(4096, "VTP Password", "Switch VTP Password is: " & $VTPPassword, 2)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Trunking is: " & $Trunking1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Spanning is: " & $PortFast1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Speed is: " & $Speed1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 VLAN is: " & $Port1)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Trunking is: " & $Trunking24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Spanning is: " & $PortFast24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Speed is: " & $Speed24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 VLAN is: " & $Port24)
     
      If FileExists(@ScriptDir & "\" & $SwitchName & ".txt") Then FileDelete(@ScriptDir & "\" & $SwitchName & ".txt")
      $SwitchFile = FileOpen(@ScriptDir & "\" & $SwitchName & ".txt", 1)
      
    ; Check if file opened for writing OK
      If $SwitchFile = -1 Then
         MsgBox(0, "Error", "Unable to open logfile.")
         Exit
      EndIf
      
    ; The following 4 lines write general switch information to the config file.
    ; Rem these lines out or do not 'cut' them to be pasted.
      FileWrite($SwitchFile, "Switch Name: " & $SwitchName & @CRLF)
      FileWrite($SwitchFile, "IP Address: " & $IPAddress & @CRLF)
      FileWrite($SwitchFile, "Gateway: " & $Gateway & @CRLF)
      FileWrite($SwitchFile, "Subnet Mask: " & $SubnetMask & @CRLF)
      FileWrite($SwitchFile, @CRLF)
      
    ; The following section is the 'header section of the switch config.
    ; This information is always the same for configs created with this application.
      FileWrite($SwitchFile, "vlan database" & @CRLF)
      FileWrite($SwitchFile, "vtp mode client" & @CRLF)
      FileWrite($SwitchFile, "VTP DOMAIN " & $VTPDomain & @CRLF)
      FileWrite($SwitchFile, "vtp V2-MODE" & @CRLF)
      FileWrite($SwitchFile, "VTP PASSWORD " & $VTPPassword & @CRLF)
      FileWrite($SwitchFile, "EXIT" & @CRLF)
      
    ; Downlink Port 1 - Default Trunk Port For Switch to Switch Connection
    ; This port is used for connection to 'lower' switches (i.e. 2900's, 1900's, etc)
      If $Port1 = ("Trunk") Then 
      FileWrite($SwitchFile, "interface FastEthernet0/1" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT TRUNK ENCAP DOT1Q" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT MODE TRUNK" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      Else
      FileWrite($SwitchFile, "interface FastEthernet0/1" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port1  & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
  EndIf
      If $Speed1 = 1 Then
          FileWrite($SwitchFile, "speed 100" & @CRLF)
          FileWrite($SwitchFile, "duplex full" & @CRLF)
          EndIf
      
    ; The following section starts the actual Port config for FA0/2 - FA0/23
      FileWrite($SwitchFile, "interface FastEthernet0/2" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port2 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/3" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port3 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/4" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port4 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/5" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port5 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/6" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port6 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/7" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port7 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/8" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port8 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/9" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port9 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/10" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port10 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/11" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port11 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/12" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port12 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/13" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port13 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/14" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port14 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/15" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port15 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/16" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port16 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/17" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port17 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/18" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port18 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/19" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port19 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/20" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port20 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/21" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port21 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/22" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port22 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/23" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port23 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
    ; UpLink Port 24 - Default Trunk Port For Switch to Switch Connection
    ; This port is used for connection to 'higher' switches (i.e. 3560's, etc)
      If $Port24 = ("Trunk") Then 
      FileWrite($SwitchFile, "interface FastEthernet0/24" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT TRUNK ENCAP DOT1Q" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT MODE TRUNK" & @CRLF)
      Else
      FileWrite($SwitchFile, "interface FastEthernet0/24" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port24  & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
  EndIf
      If $Speed24 = 1 Then
          FileWrite($SwitchFile, "speed 100" & @CRLF)
          FileWrite($SwitchFile, "duplex full" & @CRLF)
          EndIf
      
      FileWrite($SwitchFile, "" & @CRLF)
      FileWrite($SwitchFile, "" & @CRLF)
    ; The following section completes the switch config file.
      FileWrite($SwitchFile, "interface Vlan1" & @CRLF)
      FileWrite($SwitchFile, "no ip address" & @CRLF)
      FileWrite($SwitchFile, "no ip route-cache" & @CRLF)
      FileWrite($SwitchFile, "shutdown" & @CRLF)
      FileWrite($SwitchFile, "!" & @CRLF)
      FileWrite($SwitchFile, "INTERFACE VLAN 10" & @CRLF)
      FileWrite($SwitchFile, "ip address " & $IPAddress & " " & $SubnetMask & @CRLF)
      FileWrite($SwitchFile, "" & @CRLF)
      FileWrite($SwitchFile, "no ip route-cache" & @CRLF)
      FileWrite($SwitchFile, "!" & @CRLF)
      FileWrite($SwitchFile, "IP DEFAULT-GATEWAY " & $Gateway & @CRLF)
      FileWrite($SwitchFile, "Managed Hostname: " & $SwitchName & @CRLF)
            
      FileClose($SwitchFile)
      
      
   ElseIf $SwitchName = "" Or $IPAddress = "" Or $Gateway = "" Then
      MsgBox(4096, "Missing Information", "You must first enter Switch Name, IP Address & Default Gateway", 5)
   EndIf
EndFunc ;==>_WriteConfig

CatOS where are you... :o

Joe


registry victim

Share this post


Link to post
Share on other sites

Hi ZenKensei,

Did you mean something like this ?

#include <GUIConstants.au3>

Global Const $defaultVlan = "VLAN 40"
Global Const $vlanList = "VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40"

; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 642, 535, 184, 112)
$Group1 = GUICtrlCreateGroup("Switch Info", 16, 8, 257, 145)
GUICtrlCreateLabel("Switch Name:", 24, 24, 70, 17)
GUICtrlSetTip(-1, "Switch Network Name")
$ASwitchName = GUICtrlCreateInput("", 96, 24, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. MC002XNS2901")
GUICtrlCreateLabel("Switch IP:", 24, 48, 52, 17)
GUICtrlSetTip(-1, "Switch IP Address")
$ASwitchIP = GUICtrlCreateInput("", 96, 48, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "11.54.333.444")
GUICtrlCreateLabel("Switch GWY:", 24, 72, 68, 17)
GUICtrlSetTip(-1, "Switch Default Gateway")
$ASwitchGWY = GUICtrlCreateInput("", 96, 72, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 11.54.111.254")
GUICtrlCreateLabel("Switch Mask:", 24, 96, 68, 17)
GUICtrlSetTip(-1, "Switch Subnet Mask")
$ASwitchMask = GUICtrlCreateInput("255.255.254.0", 96, 96, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 255.255.254.0")
GUICtrlCreateLabel("Switch Loc:", 24, 120, 60, 17)
GUICtrlSetTip(-1, "Switch Location")
$ASwitchLoc = GUICtrlCreateInput("1FL MDF Rack 1 Position 1", 96, 120, 161, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. 1FL - MDF Rack 1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "General Switch Info")

$Group2 = GUICtrlCreateGroup("Port 1 Configuration", 288, 8, 161, 145)
$ATrunking1 = GUICtrlCreateCheckbox("Trunking Enabled", 304, 32, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, " FA0/1 Trunking On")
$APortFast1 = GUICtrlCreateCheckbox("PortFast Enabled", 304, 56, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/1 PortFast Spanning")
$APort1 = GUICtrlCreateCombo("", 304, 120, 113, 21)
GUICtrlSetData(-1, "TRUNK|VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40","TRUNK")
GuiCtrlSetState($APort1,$GUI_DISABLE)
GUICtrlSetTip(-1, "VLAN Access Mode")
$ASpeed1 = GUICtrlCreateCheckbox("100Mb / Full Duplex", 304, 80, 129, 17)
GUICtrlSetTip(-1, "Set Speed to 100mb / Full Duplex")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "FA0/1 Config")
$Group3 = GUICtrlCreateGroup("Port 24 Configuration", 464, 8, 161, 145)
$ATrunking24 = GUICtrlCreateCheckbox("Trunking Enabled", 480, 32, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/24 Trunking On")
$APortFast24 = GUICtrlCreateCheckbox("PortFast Enabled", 480, 56, 105, 17)
; GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "FA0/24 PortFast Spanning")
$APort24 = GUICtrlCreateCombo("", 480, 120, 113, 21)
GUICtrlSetData(-1, "TRUNK|VLAN 1|VLAN 10|VLAN 20|VLAN 30|VLAN 40","TRUNK")
GUICtrlSetTip(-1, "VLAN Access Mode")
GuiCtrlSetState($APort24,$GUI_DISABLE)
$ASpeed24 = GUICtrlCreateCheckbox("100Mb / Full Duplex", 480, 80, 129, 17)
GUICtrlSetTip(-1, "Set Speed to 100mb / Full Duplex")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "Port 24 Uplink Config")

$Group4 = GUICtrlCreateGroup("Standard Port Configuration", 16, 232, 609, 233)
GUICtrlCreateLabel("Port FA0/2", 32, 256, 56, 17)
GUICtrlSetTip(-1, "FA0/2 VLAN Access")
$APort2 = GUICtrlCreateCombo("", 32, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 2 VLAN Access")
GUICtrlCreateLabel("Port FA0/3", 32, 304, 56, 17)
GUICtrlSetTip(-1, "FA0/3 VLAN Access")
$APort3 = GUICtrlCreateCombo("", 32, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 3 VLAN Access")
GUICtrlCreateLabel("Port FA0/4", 32, 352, 56, 17)
GUICtrlSetTip(-1, "FA0/4 VLAN Access")
$APort4 = GUICtrlCreateCombo("", 32, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 4 VLAN Access")
GUICtrlCreateLabel("Port FA0/5", 32, 400, 56, 17)
GUICtrlSetTip(-1, "FA0/5 VLAN Access")
$APort5 = GUICtrlCreateCombo("", 32, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 5 VLAN Access")
GUICtrlCreateLabel("Port FA0/6", 128, 256, 56, 17)
GUICtrlSetTip(-1, "FA0/6 VLAN Access")
$APort6 = GUICtrlCreateCombo("", 128, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 6 VLAN Access")
GUICtrlCreateLabel("Port FA0/7", 128, 304, 56, 17)
GUICtrlSetTip(-1, "FA0/7 VLAN Access")
$APort7 = GUICtrlCreateCombo("", 128, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 7 VLAN Access")
GUICtrlCreateLabel("Port FA0/8", 128, 352, 56, 17)
GUICtrlSetTip(-1, "FA0/8 VLAN Access")
$APort8 = GUICtrlCreateCombo("", 128, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 8 VLAN Access")
GUICtrlCreateLabel("Port FA0/9", 128, 400, 56, 17)
GUICtrlSetTip(-1, "FA0/9 VLAN Access")
$APort9 = GUICtrlCreateCombo("", 128, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 9 VLAN Access")
GUICtrlCreateLabel("Port FA0/10", 224, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/10 VLAN Access")
$APort10 = GUICtrlCreateCombo("", 224, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 10 VLAN Access")
GUICtrlCreateLabel("Port FA0/11", 224, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/11 VLAN Access")
$APort11 = GUICtrlCreateCombo("", 224, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlCreateLabel("Port FA0/12", 224, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/12 VLAN Access")
$APort12 = GUICtrlCreateCombo("", 224, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlCreateLabel("Port FA0/13", 224, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/13 VLAN Access")
$APort13 = GUICtrlCreateCombo("", 224, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlCreateLabel("Port FA0/14", 328, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/14 VLAN Access")
$APort14 = GUICtrlCreateCombo("", 328, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 14 VLAN Access")
GUICtrlCreateLabel("Port FA0/15", 328, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/15VLAN Access")
$APort15 = GUICtrlCreateCombo("", 328, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 15 VLAN Access")
GUICtrlCreateLabel("Port FA0/16", 328, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/16 VLAN Access")
$APort16 = GUICtrlCreateCombo("", 328, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 16 VLAN Access")
GUICtrlCreateLabel("Port FA0/17", 328, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/17 VLAN Access")
$APort17 = GUICtrlCreateCombo("", 328, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 17 VLAN Access")
GUICtrlCreateLabel("Port FA0/18", 432, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/18 VLAN Access")
$APort18 = GUICtrlCreateCombo("", 432, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 18 VLAN Access")
GUICtrlCreateLabel("Port FA0/19", 432, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/19 VLAN Access")
$APort19 = GUICtrlCreateCombo("", 432, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 19 VLAN Access")
GUICtrlCreateLabel("Port FA0/20", 432, 352, 62, 17)
GUICtrlSetTip(-1, "FA0/20 VLAN Access")
$APort20 = GUICtrlCreateCombo("", 432, 368, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 20 VLAN Access")
GUICtrlCreateLabel("Port FA0/21", 432, 400, 62, 17)
GUICtrlSetTip(-1, "FA0/21 VLAN Access")
$APort21 = GUICtrlCreateCombo("", 432, 416, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 21 VLAN Access")
GUICtrlCreateLabel("Port FA0/22", 528, 256, 62, 17)
GUICtrlSetTip(-1, "FA0/22 VLAN Access")
$APort22 = GUICtrlCreateCombo("", 528, 272, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 22 VLAN Access")
GUICtrlCreateLabel("Port FA0/23", 528, 304, 62, 17)
GUICtrlSetTip(-1, "FA0/23 VLAN Access")
$APort23 = GUICtrlCreateCombo("", 528, 320, 73, 21)
GUICtrlSetData(-1, $vlanList,$defaultVlan)
GUICtrlSetTip(-1, "Port 23 VLAN Access")
GUICtrlCreateLabel("", 528, 352, 4, 4)
GUICtrlCreateLabel("All ports are auto", 528, 352, 83, 17)
GUICtrlCreateLabel("speed and duplex.", 528, 368, 91, 17)
GUICtrlCreateLabel("All ports are", 528, 384, 59, 17)
GUICtrlCreateLabel("VLAN 40 by", 528, 400, 61, 17)
GUICtrlCreateLabel("default.", 528, 416, 39, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "FA0/2 - FA0/23 Configs")
$Button1 = GUICtrlCreateButton("Write Config File", 136, 480, 97, 25)
GUICtrlSetTip(-1, "Create config file")
$Button2 = GUICtrlCreateButton("Clear Form", 272, 480, 97, 25)
GUICtrlSetTip(-1, "Clear the form")
$Button3 = GUICtrlCreateButton("Exit", 408, 480, 81, 25)
GUICtrlSetTip(-1, "Exit Application")
$Group5 = GUICtrlCreateGroup("VTP Information", 16, 160, 257, 65)
GUICtrlCreateLabel("VTP Domain:", 24, 176, 67, 17)
GUICtrlSetTip(-1, "VTP Domain Name")
$AVTPDomain = GUICtrlCreateInput("", 104, 176, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. FLO700X")
GUICtrlCreateLabel("VTP Password:", 24, 200, 77, 17)
GUICtrlSetTip(-1, "VTP Server Password")
$AVTPPassword = GUICtrlCreateInput("", 104, 200, 105, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "ex. FLO700X")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetTip(-1, "VTP Server Info")

; GUISetState(@SW_SHOW)

GUISetState()

$msg = 0

While $msg <> $GUI_EVENT_Close
   $msg = GUIGetMsg()
   Select
      Case $msg == ($Button1)
         _WriteConfig(GUICtrlRead($ASwitchName))
         
      Case $msg == ($Button2)
          _clearForm()
          
      Case $msg == $ATrunking1
    If GuiCtrlRead($ATrunking1) == $GUI_CHECKED Then
        GuiCtrlSetData($APort1, "TRUNK|" & $vlanList,"TRUNK")
        GuiCtrlSetState($APort1,$GUI_DISABLE)
    Else
        GuiCtrlSetData($APort1,"TRUNK|" & $vlanList,$defaultVlan)
        GuiCtrlSetState($APort1,$GUI_ENABLE)    
    EndIf

      Case $msg == $ATrunking24
    If GuiCtrlRead($ATrunking24) == $GUI_CHECKED Then
        GuiCtrlSetData($APort24, "TRUNK|" & $vlanList,"TRUNK")
        GuiCtrlSetState($APort24,$GUI_DISABLE)
    Else
        GuiCtrlSetData($APort24,"TRUNK|" & $vlanList,$defaultVlan)
        GuiCtrlSetState($APort24,$GUI_ENABLE)   
    EndIf

      Case $msg == ($Button3)
         MsgBox(0, "EXIT", "Exiting Cisco Config", 2)
         Exit
   EndSelect
WEnd
Exit

; clear (at least partially the display)
Func _clearForm()
; clear id infos
    GuiCtrlSetData($ASwitchName ,"")
    GuiCtrlSetData($ASwitchIP   ,"")
    GuiCtrlSetData($ASwitchGWY  ,"")
    GuiCtrlSetData($ASwitchMask ,"255.255.254.0")
    GuiCtrlSetData($ASwitchLoc  ,"1FL MDF Rack 1 Position 1")
; clear ports 2-23
For $i= 2 To 23
    GuiCtrlSetData(Eval("APort" & $i),$vlanList,$defaultVlan)
Next
; clear ports 1; 24
    GuiCtrlSetData($APort1, "TRUNK|" & $vlanList,"TRUNK")
    GuiCtrlSetState($APort1,$GUI_DISABLE)
    GuiCtrlSetData($APort24, "TRUNK|" & $vlanList,"TRUNK")
    GuiCtrlSetState($APort24,$GUI_DISABLE)

; clear vtp infos
    GuiCtrlSetData($AVTPDomain  ,"")
    GuiCtrlSetData($AVTPPassword    ,"")
EndFunc

Func _WriteConfig($ASwitchName)
   $SwitchName = $ASwitchName
   $IPAddress = (GUICtrlRead($ASwitchIP))
   $Gateway = (GUICtrlRead($ASwitchGWY))
   $SubnetMask = (GUICtrlRead($ASwitchMask))
   $VTPDomain = (GUICtrlRead($AVTPDomain))
   $VTPPassword = (GUICtrlRead($AVTPPassword))
   $Trunking1 = (GUICtrlRead($ATrunking1))
   $PortFast1 = (GUICtrlRead($APortFast1))
   $Speed1 = (GUICtrlRead($ASpeed1))
   $Port1 = (GUICtrlRead($APort1))
   $Trunking24 = (GUICtrlRead($ATrunking24))
   $PortFast24 = (GUICtrlRead($APortFast24))
   $Speed24 = (GUICtrlRead($ASpeed24))
   $Port24 = (GUICtrlRead($APort24))
   
   
   If $SwitchName <> "" And $IPAddress <> "" And $Gateway <> "" Then
      
      $Port1 = (GUICtrlRead($APort1))
      If $Port1 = "" Then $Port1 = ("TRUNK")
      $Trunking1 = (GUICtrlRead($ATrunking1))
      $PortFast1 = (GUICtrlRead($APortFast1))
      $Speed1 = (GUICtrlRead($ASpeed1))
      $Port2 = (GUICtrlRead($APort2))
      If $Port2 = "" Then $Port2 = ("VLAN 40")
      $Port3 = (GUICtrlRead($APort3))
      If $Port3 = "" Then $Port3 = ("VLAN 40")
      $Port4 = (GUICtrlRead($APort4))
      If $Port4 = "" Then $Port4 = ("VLAN 40")
      $Port5 = (GUICtrlRead($APort5))
      If $Port5 = "" Then $Port5 = ("VLAN 40")
      $Port6 = (GUICtrlRead($APort6))
      If $Port6 = "" Then $Port6 = ("VLAN 40")
      $Port7 = (GUICtrlRead($APort7))
      If $Port7 = "" Then $Port7 = ("VLAN 40")
      $Port8 = (GUICtrlRead($APort8))
      If $Port8 = "" Then $Port8 = ("VLAN 40")
      $Port9 = (GUICtrlRead($APort9))
      If $Port9 = "" Then $Port9 = ("VLAN 40")
      $Port10 = (GUICtrlRead($APort10))
      If $Port10 = "" Then $Port10 = ("VLAN 40")
      $Port11 = (GUICtrlRead($APort11))
      If $Port11 = "" Then $Port11 = ("VLAN 40")
      $Port12 = (GUICtrlRead($APort12))
      If $Port12 = "" Then $Port12 = ("VLAN 40")
      $Port13 = (GUICtrlRead($APort13))
      If $Port13 = "" Then $Port13 = ("VLAN 40")
      $Port14 = (GUICtrlRead($APort14))
      If $Port14 = "" Then $Port14 = ("VLAN 40")
      $Port15 = (GUICtrlRead($APort15))
      If $Port15 = "" Then $Port15 = ("VLAN 40")
      $Port16 = (GUICtrlRead($APort16))
      If $Port16 = "" Then $Port16 = ("VLAN 40")
      $Port17 = (GUICtrlRead($APort17))
      If $Port17 = "" Then $Port17 = ("VLAN 40")
      $Port18 = (GUICtrlRead($APort18))
      If $Port18 = "" Then $Port18 = ("VLAN 40")
      $Port19 = (GUICtrlRead($APort19))
      If $Port19 = "" Then $Port19 = ("VLAN 40")
      $Port20 = (GUICtrlRead($APort20))
      If $Port20 = "" Then $Port20 = ("VLAN 40")
      $Port21 = (GUICtrlRead($APort21))
      If $Port21 = "" Then $Port21 = ("VLAN 40")
      $Port22 = (GUICtrlRead($APort22))
      If $Port22 = "" Then $Port22 = ("VLAN 40")
      $Port23 = (GUICtrlRead($APort23))
      If $Port23 = "" Then $Port23 = ("VLAN 40")
      $Port24 = (GUICtrlRead($APort24))
      If $Port24 = "" Then $Port24 = ("TRUNK")
      $Trunking24 = (GUICtrlRead($ATrunking24))
      $PortFast24 = (GUICtrlRead($APortFast24))
      $Speed24 = (GUICtrlRead($ASpeed24))
            
      MsgBox(4096, "Switch Name", "Switch Network Name is: " & $SwitchName, 2)
      MsgBox(4096, "IP Address", "Switch Gateway IP Address is: " & $IPAddress, 2)
; MsgBox(4096, "Defualt Gateway", "Switch Gateway IP Address is: " & $Gateway, 2)
; MsgBox(4096, "Subnet Mask", "Switch Subnet Mask is: " & $SubnetMask, 2)
; MsgBox(4096, "VTP Domain", "Switch VTP Domain is: " & $VTPDomain, 2)
; MsgBox(4096, "VTP Password", "Switch VTP Password is: " & $VTPPassword, 2)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Trunking is: " & $Trunking1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Spanning is: " & $PortFast1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 Speed is: " & $Speed1)
      MsgBox(4096, "Port FA0/1", "Port FA0/1 VLAN is: " & $Port1)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Trunking is: " & $Trunking24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Spanning is: " & $PortFast24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 Speed is: " & $Speed24)
      MsgBox(4096, "Port FA0/24", "Port FA0/24 VLAN is: " & $Port24)
     
      If FileExists(@ScriptDir & "\" & $SwitchName & ".txt") Then FileDelete(@ScriptDir & "\" & $SwitchName & ".txt")
      $SwitchFile = FileOpen(@ScriptDir & "\" & $SwitchName & ".txt", 1)
      
; Check if file opened for writing OK
      If $SwitchFile = -1 Then
         MsgBox(0, "Error", "Unable to open logfile.")
         Exit
      EndIf
      
; The following 4 lines write general switch information to the config file.
; Rem these lines out or do not 'cut' them to be pasted.
      FileWrite($SwitchFile, "Switch Name: " & $SwitchName & @CRLF)
      FileWrite($SwitchFile, "IP Address: " & $IPAddress & @CRLF)
      FileWrite($SwitchFile, "Gateway: " & $Gateway & @CRLF)
      FileWrite($SwitchFile, "Subnet Mask: " & $SubnetMask & @CRLF)
      FileWrite($SwitchFile, @CRLF)
      
; The following section is the 'header section of the switch config.
; This information is always the same for configs created with this application.
      FileWrite($SwitchFile, "vlan database" & @CRLF)
      FileWrite($SwitchFile, "vtp mode client" & @CRLF)
      FileWrite($SwitchFile, "VTP DOMAIN " & $VTPDomain & @CRLF)
      FileWrite($SwitchFile, "vtp V2-MODE" & @CRLF)
      FileWrite($SwitchFile, "VTP PASSWORD " & $VTPPassword & @CRLF)
      FileWrite($SwitchFile, "EXIT" & @CRLF)
      
; Downlink Port 1 - Default Trunk Port For Switch to Switch Connection
; This port is used for connection to 'lower' switches (i.e. 2900's, 1900's, etc)
      If $Port1 = ("Trunk") Then 
      FileWrite($SwitchFile, "interface FastEthernet0/1" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT TRUNK ENCAP DOT1Q" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT MODE TRUNK" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      Else
      FileWrite($SwitchFile, "interface FastEthernet0/1" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port1  & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
  EndIf
      If $Speed1 = 1 Then
          FileWrite($SwitchFile, "speed 100" & @CRLF)
          FileWrite($SwitchFile, "duplex full" & @CRLF)
          EndIf
      
; The following section starts the actual Port config for FA0/2 - FA0/23
      FileWrite($SwitchFile, "interface FastEthernet0/2" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port2 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/3" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port3 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/4" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port4 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/5" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port5 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/6" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port6 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/7" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port7 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/8" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port8 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/9" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port9 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/10" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port10 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/11" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port11 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/12" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port12 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/13" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port13 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/14" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port14 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/15" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port15 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/16" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port16 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/17" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port17 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/18" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port18 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/19" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port19 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/20" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port20 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/21" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port21 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/22" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port22 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
      FileWrite($SwitchFile, "interface FastEthernet0/23" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port23 & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
      
; UpLink Port 24 - Default Trunk Port For Switch to Switch Connection
; This port is used for connection to 'higher' switches (i.e. 3560's, etc)
      If $Port24 = ("Trunk") Then 
      FileWrite($SwitchFile, "interface FastEthernet0/24" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT TRUNK ENCAP DOT1Q" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT MODE TRUNK" & @CRLF)
      Else
      FileWrite($SwitchFile, "interface FastEthernet0/24" & @CRLF)
      FileWrite($SwitchFile, "SWITCHPORT ACCESS " & $Port24  & @CRLF)
      FileWrite($SwitchFile, "switchport mode access" & @CRLF)
      FileWrite($SwitchFile, "spanning-tree portfast" & @CRLF)
      FileWrite($SwitchFile, "cdp enable" & @CRLF)
  EndIf
      If $Speed24 = 1 Then
          FileWrite($SwitchFile, "speed 100" & @CRLF)
          FileWrite($SwitchFile, "duplex full" & @CRLF)
          EndIf
      
      FileWrite($SwitchFile, "" & @CRLF)
      FileWrite($SwitchFile, "" & @CRLF)
; The following section completes the switch config file.
      FileWrite($SwitchFile, "interface Vlan1" & @CRLF)
      FileWrite($SwitchFile, "no ip address" & @CRLF)
      FileWrite($SwitchFile, "no ip route-cache" & @CRLF)
      FileWrite($SwitchFile, "shutdown" & @CRLF)
      FileWrite($SwitchFile, "!" & @CRLF)
      FileWrite($SwitchFile, "INTERFACE VLAN 10" & @CRLF)
      FileWrite($SwitchFile, "ip address " & $IPAddress & " " & $SubnetMask & @CRLF)
      FileWrite($SwitchFile, "" & @CRLF)
      FileWrite($SwitchFile, "no ip route-cache" & @CRLF)
      FileWrite($SwitchFile, "!" & @CRLF)
      FileWrite($SwitchFile, "IP DEFAULT-GATEWAY " & $Gateway & @CRLF)
      FileWrite($SwitchFile, "Managed Hostname: " & $SwitchName & @CRLF)
            
      FileClose($SwitchFile)
      
      
   ElseIf $SwitchName = "" Or $IPAddress = "" Or $Gateway = "" Then
      MsgBox(4096, "Missing Information", "You must first enter Switch Name, IP Address & Default Gateway", 5)
   EndIf
EndFunc;==>_WriteConfig

CatOS where are you... :o

Joe

Joe,

Yes, its nearly perfect. I found a couple of things that I think were unexpected in your code though.

1) Every time you hit the clear button, it would add an additional listing of VLAN's to the drop down boxes, so if you hit clear twice you then have VLAN1, VLAN10, VLAN20, VLAN30, VLAN40, VLAN1, VLAN10, VLAN30, VLAN40, etc. I believe I have corrected this by modifying line 247 as follows:

Old = GuiCtrlSetData(Eval("APort" & $i),$vlanList,$defaultVlan)
New = GuiCtrlSetData(Eval("APort" & $i),$defaultVlan)

removing the part for adding the $vlanlist each time the clear button is pressed. This seems to work for all of the ports 2 - 23, however, with ports 1 & 24 I seem to be missing some logic, I can't keep the additional VLANs from showing up, and when I press the 'Clear' button the 'Trunking' checkmark box does not default back to a 'checked' state. Seems like I'm missing something on that one. I tried adding the following in the section for clearing ports 1 & 24 but it seems to have no effect.

GuiCtrlSetData($ATrunking1,"Trunking Enabled")
GUICtrlSetState(-1, $GUI_CHECKED)

Let me know if you have any suggestions on this one

And again, thanks for taking a look at this in the first place....

ZenKensei

Share this post


Link to post
Share on other sites

Hello ZenKensei,

I'm afraid i did not properly checked the code i send to you. I just cut and paste the .bak. :o

You're right for the combo-box i forget to erase the previous content with a leading pipe "|". Correct code should be:

GuiCtrlSetData(Eval("APort" & $i),"|" & $vlanList,$defaultVlan)
; as i thought it could be quite interesting to let someone choose and add new vlans numbers for some
; particular switches - and that these specials vlans should be remove from the "default config"
; -> so the solution in the clear code is: 
; "|" ...erase previous list
; & $vlanlist ... revert to good old vlan list
; $defaultvlan ... defaultvlan :)

For the logic of ports 1 & 24 i assumed that you wanted the two ports trunked by default ,so vlan should be trunk and disabled until you uncheck "trunking enable"

The correct code with the checkbox reflecting the default state when cleared should be (according to this logic)

; clear ports 1; 24
    GuiCtrlSetData($APort1, "|TRUNK|" & $vlanList,"TRUNK")
    GuiCtrlSetState($APort1,$GUI_DISABLE)
    GuiCtrlSetState($ATrunking1,$GUI_CHECKED)
    
    GuiCtrlSetData($APort24, "|TRUNK|" & $vlanList,"TRUNK")
    GuiCtrlSetState($APort24,$GUI_DISABLE)
    GuiCtrlSetState($ATrunking24,$GUI_CHECKED)

As always its a matter of interpretation. For example i'm not sure that it is wise to clear the vtp domain information, assuming that if you need this kind of gui you should have a lot of Ciscos in the same vtp domain (only 24 ports models? :geek: )

Hope i will find some time soon to make a tool to manage my 3550s and 2970s...

Regards


registry victim

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
Sign in to follow this  
Followers 0