Jump to content

Service start/stop Tool


pranaynanda
 Share

Recommended Posts

Okay guys, here's what I've got. Because I have it due to the community, I thought of giving it back. It might help some times.

#include <GuiListView.au3>
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#RequireAdmin

Dim $Services
Dim $ServicesList

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Service Manager", 677, 438, 192, 124)

$Label1 = GUICtrlCreateLabel("Service Manager", 8, 0, 235, 46)
GUICtrlSetFont($Label1, 27, 800, 2, "Arial Narrow")
GUICtrlSetColor($Label1, 0x0066CC)

$Tab1 = GUICtrlCreateTab(0, 48, 676, 385)
$TabSheet1 = GUICtrlCreateTabItem("Running Services")
$ListView1 = GUICtrlCreateListView("Service Display Name|Service Name|Status", 2, 72, 670, 281, -1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 0, 300)
GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 1, 288)
GUICtrlSendMsg($ListView1, $LVM_SETCOLUMNWIDTH, 2, 88)
$Button1 = GUICtrlCreateButton("Stop Services", 464, 376, 129, 33)

$TabSheet2 = GUICtrlCreateTabItem("Stopped Services")
GUICtrlSetState(-1,$GUI_SHOW)
$ListView2 = GUICtrlCreateListView("Service Display Name|Service Name|Status", 2, 72, 670, 281, -1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT))
GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 0, 300)
GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 1, 288)
GUICtrlSendMsg($ListView2, $LVM_SETCOLUMNWIDTH, 2, 88)
$Button2 = GUICtrlCreateButton("Start Services", 464, 376, 129, 33)



$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenuItem("Select All", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenuItem("Unselect All", $MenuItem1)
$MenuItem4 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenu("Help")
$MenuItem6 = GUICtrlCreateMenuItem("Help Topics", $MenuItem5)
$MenuItem7 = GUICtrlCreateMenuItem("About", $MenuItem5)


GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_populate()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
            _start()
         Case $Button2
            _stop()
         Case $MenuItem2
            _selectall()
         Case $MenuItem3
            _UnselectAll()
         Case $MenuItem4
            Exit
        Case $MenuItem6
            _HelpTopics()
        Case $MenuItem7
            _AboutProject()
    EndSwitch
WEnd

Func _populate()
    Global $Services = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
    Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service")
    If IsObj($ServicesList) then
        _GUICtrlListView_BeginUpdate($ListView1)
        _GUICtrlListView_BeginUpdate($ListView2)
        _GUICtrlListView_DeleteAllItems($ListView1)
        _GUICtrlListView_DeleteAllItems($ListView2)
        For $Services in $ServicesList
            if $Services.State = "Running" Then
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView1)
            Else
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView2)
            EndIf
         Next
         _GUICtrlListView_EndUpdate($ListView1)
        _GUICtrlListView_EndUpdate($ListView2)
    EndIf
 EndFunc

Func _start()
   Dim $sArray[1]
   $count = _GUICtrlListView_GetItemCount($ListView1)
    $aCount = 0
    For $i = 1 To $count Step 1
        If _GUICtrlListView_GetItemChecked($ListView1, $i-1)  = True Then
            $sArray[$aCount]=_GUICtrlListView_GetItemText($ListView1, $i - 1, 1)
            ReDim $sArray[UBound($sArray) + 1]
            $aCount += 1
        EndIf
     Next

   ProgressOn("Stop services", "Stopping" & $sArray, "", -1, -1, 16)

   For $i = 1 To UBound($sArray) - 1 Step 1
      $service = $sArray[$i - 1]
      RunWait("net stop " & $service)
      ProgressSet($i / (UBound($sArray) - 1) * 100, Round($i / (UBound($sArray) - 1) * 100, 0) & "%", "Stopping " & $i & " of " & UBound($sArray) - 1)
   Next
   Sleep(5000)
   ProgressOff()
   _populate()
;   ReDim(_populate())
EndFunc

Func _stop()
   Dim $sArray[1]
   $count = _GUICtrlListView_GetItemCount($ListView2)
    $aCount = 0
    For $i = 1 To $count Step 1
        If _GUICtrlListView_GetItemChecked($ListView2, $i - 1) = True Then
            $sArray[$aCount] = _GUICtrlListView_GetItemText($ListView2, $i - 1,1)
            ReDim $sArray[UBound($sArray) + 1]
            $aCount += 1
        EndIf
     Next

      ProgressOn("Starting services", "Starting" & $sArray, "", -1, -1, 16)

   For $i = 1 To UBound($sArray) - 1 Step 1
      $service = $sArray[$i - 1]
      RunWait("net start " & $service)
      ProgressSet($i / (UBound($sArray) - 1) * 100, Round($i / (UBound($sArray) - 1) * 100, 0) & "%", "Starting " & $i & " of " & UBound($sArray) - 1)
   Next
   Sleep(5000)
   ProgressOff()
   _populate()
   ;ReDim(_populate())
EndFunc

Func _selectAll()
    _GUICtrlListView_SetItemChecked($ListView1, - 1, True)
    _GUICtrlListView_SetItemChecked($ListView2, - 1, True)
EndFunc

Func _UnselectAll()
         _GUICtrlListView_SetItemChecked($ListView1, - 1, False)

         _GUICtrlListView_SetItemChecked($ListView2, - 1, False)


EndFunc

Func _HelpTopics()
    $Form2 = GUICreate("Help Topics", 800, 400)
    $Label1 = GUICtrlCreateLabel("", 8, 16, 750, 350)
    GUICtrlSetFont(-1, 24, 300, 2, "Arial")
    GUICtrlSetColor(-1, 0x0066CC)
    $info="This Program uses collects all sevices from Windows (services.msc) and categorizes them according to their status (Running or Stopped)." & @CRLF & @CRLF & "It then uses Windows" & @CRLF & "net start <servicename> or net stop <servicename>" & @CR &"commands to start or stop multiple services based on their selection via checkboxes."
    GUISetState(@SW_SHOW)
   GUICtrlSetData(-1, $info)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form2)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_HelpTopics

Func _AboutProject()
    $Form3 = GUICreate("About", 413, 196)
    $Label1a = GUICtrlCreateLabel("", 24, 64, 364, 130)
    $Label2a = GUICtrlCreateLabel("Service Manager", 24, 8, 375, 41)
    GUICtrlSetFont(-1, 24, 900, 2, "Arial")
    GUICtrlSetColor(-1, 0x0066CC)
      GUISetState(@SW_SHOW)
      #cs
    $Form3 = GUICreate("About", 700, 400)
   ; $Label1a = GUICtrlCreateLabel("", 24, 64, 364, 113)
    $Label2a = GUICtrlCreateLabel("Service Manager", 24, 8, 375, 41)
    GUICtrlSetFont($Label2a, 24, 300, 2, "Arial")
    GUICtrlSetColor($Label2a, 0x000080)
    GUISetState(@SW_SHOW)
    #ce
    $aboutData = "This program was written in a programming language called Autoit by"
  ; $string = ""
    ;For $i = 1 To UBound($sData) Step 1
        ;$string = $string & @CRLF & $sData[$i - 1] & @CRLF
        GUICtrlSetData($Label1a, $aboutData)
        GUICtrlSetFont($Label1a, 16, 900, 2, "Arial")
      GUICtrlSetColor($Label1a, 0x0066CC)
   ;Next

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form3)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_AboutProject

#cs
Imporvement points:
1.Better GUI
2. Select remote machine
3. Progress Bar
4. Silent Mode
#ce

My future scope with this is to get it work across all my servers from my location. My thoughts are to make a configuration file to pass the credentials and then further use a switch case statement to get this to work. What are your thoughts?

Link to comment
Share on other sites

8 hours ago, pranaynanda said:

Okay people, some serious help needed here. How do I get the same logic to work on a different machine in different or same network and logged in as different user?

To make it work with different machine add an Edit control and another button to reload the services.

Then modify the _populate() function to pass the computer name into it so would read the services from the remote computer.

Func _populate($strComputerName = 'localhost')
    Global $Services = ObjGet("winmgmts:\\" & $strComputerName & "\root\cimv2")
    Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service")
    If IsObj($ServicesList) then
        _GUICtrlListView_BeginUpdate($ListView1)
        _GUICtrlListView_BeginUpdate($ListView2)
        _GUICtrlListView_DeleteAllItems($ListView1)
        _GUICtrlListView_DeleteAllItems($ListView2)
        For $Services in $ServicesList
            if $Services.State = "Running" Then
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView1)
            Else
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView2)
            EndIf
         Next
         _GUICtrlListView_EndUpdate($ListView1)
        _GUICtrlListView_EndUpdate($ListView2)
    EndIf
 EndFunc

Also instead of using Net Stop or Net Start use the command line called SC which allow you to control services on remote computers.

  • SC \\ServerName start "Service Name"
  • SC \\ServerName stop "Service Name"

Note:

       When I ran your script on my computer the functions called _selectAll() and _UnselectAll() didn't work.  You need to declare $ListView1 and $ListView2 as Global variables.

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

@Danny35d Thank you! My apologies if those functions didn't work on your system. But they do perfectly fine on my computer. Try relaunching the script. Also because I had thought of changing the computer name via a menu button or a combo box, how do I change the value of localhost that is the parameter for the function? Can i make the variable $strComputerName a global variable to get this to work? Also, do I need to do a workaround for credentials?

Edited by pranaynanda
Incomplete post
Link to comment
Share on other sites

On 4/1/2016 at 9:01 PM, Danny35d said:
Func _populate($strComputerName = 'localhost')
    Global $Services = ObjGet("winmgmts:\\" & $strComputerName & "\root\cimv2")
    Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service")
    If IsObj($ServicesList) then
        _GUICtrlListView_BeginUpdate($ListView1)
        _GUICtrlListView_BeginUpdate($ListView2)
        _GUICtrlListView_DeleteAllItems($ListView1)
        _GUICtrlListView_DeleteAllItems($ListView2)
        For $Services in $ServicesList
            if $Services.State = "Running" Then
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView1)
            Else
               GUICtrlCreateListViewItem( $Services.DisplayName & "|" & $Services.Name & "|" & $Services.State , $ListView2)
            EndIf
         Next
         _GUICtrlListView_EndUpdate($ListView1)
        _GUICtrlListView_EndUpdate($ListView2)
    EndIf
 EndFunc

That works! Thank you. But can anyone explain why this does not?

Global $machine="secretmachinename"

Func _populate($computer=$machine)
    Global $Services = ObjGet("winmgmts:\\" & $computer & "\root\cimv2")
    Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service")

 

Link to comment
Share on other sites

On 4/2/2016 at 9:32 AM, pranaynanda said:

@Danny35d Thank you! My apologies if those functions didn't work on your system. But they do perfectly fine on my computer. Try relaunching the script. Also because I had thought of changing the computer name via a menu button or a combo box, how do I change the value of localhost that is the parameter for the function? Can i make the variable $strComputerName a global variable to get this to work? Also, do I need to do a workaround for credentials?

I learn the hard way, did several script the work perfect on my computer, but when I used them on others computers some of my functions  won't work.  If I have a variable on my main part of the script that I need to use within a function I declare that variable as Global that way it will always work no matter which computer I'm running the script.  In your case $ListView1 and $ListView2 work fine in your computer, but not in my computer.  At soon I add them as a Global variable work fine in my computer and must like it will work on your computer.

Yes, to change the computer name via a menu or combo box you should make it a global variable.  I won't worry for credentials because the computer will used the login credentials to execute the commands.  If you want to run your script as another user you can always hold down shift key and then right click your script choose "run as different user."

If you still want to added to your script a workaround for credentials, then you have to ask for the username and password somewhere in your script and use RunAs() or RunAsWait() to execute the command lines.

Quote

That works! Thank you. But can anyone explain why this does not?

Global $machine="secretmachinename"

Func _populate($computer=$machine)
    Global $Services = ObjGet("winmgmts:\\" & $computer & "\root\cimv2")
    Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service")

I modify the script in my computer these are the results calling the function:

  • _populate()   Works fine.
  • _populate($machine)   Works fine.
  • _populate('') Doesn't work

So It should work all depend how you called the function.  Looking at your posted example I don't know how you called the _populate() function.

 

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

The original post has the entire code.

13 hours ago, Danny35d said:

I won't worry for credentials because the computer will used the login credentials to execute the commands.  If you want to run your script as another user you can always hold down shift key and then right click your script choose "run as different user."

Also, as I said, this is how I want my script to do the job. I am a system administrator. I want to fetch services running on a remote machine on which a different user is logged in. I want to be able to do that from my computer and me as the user. The user logged in on that machine is a dummy account and a non-human user. The machine can be in my domain or a different domain. What worries me is the tendency that I will not get through windows authentication.

Secondly, I could not see "Run as different user" on holding shift and right-clicking.

 

13 hours ago, Danny35d said:

If you still want to added to your script a workaround for credentials, then you have to ask for the username and password somewhere in your script and use RunAs() or RunAsWait() to execute the command lines.

Also, as far as I have been into documentation, RunAs() or RunAsWait() are used for an external program. If I want to use that how do I do it with my code? Will I have to make another script that calls the original one as an external program so that I may be able to run it as an authenticated user?

13 hours ago, Danny35d said:

I modify the script in my computer these are the results calling the function:

  • _populate()   Works fine.
  • _populate($machine)   Works fine.
  • _populate('') Doesn't work

So It should work all depend how you called the function.  Looking at your posted example I don't know how you called the _populate() function.

Finally, much gratitude for that. That did solve some piece of concern.

Now it works like this:

Func _populate($computer)
    Global $Services = ObjGet("winmgmts:\\" & $computer & "\root\cimv2")

If I declare the variable $machine="secretmachinename" and call it as _populate($machine).

Edited by pranaynanda
Link to comment
Share on other sites

Okay guys. Thank you. I think I got it working.

For $i = 1 To UBound($sArray) - 1 Step 1
      $service = $sArray[$i - 1]
      RunWait("sc \\" & "secretmachinename" & " stop "  & $service)

I just had to be authorized enough to get it working on a remote machine. Special word of gratitude for @Danny35d for the support.

A final piece of help would be how to derive values in a combo box based on the input to another combo box. An example case would be listing cities in $combobox2 based on country selected in $combobox1.

$Combo1 = GUICtrlCreateCombo("", 144, 48, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "123|456|789|0")
$Combo2 = GUICtrlCreateCombo("", 304, 48, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "ABC|DEF|GHI|JKL|MNO|PQR|STU|VWX|YZ")

So let's say if I select "123" from $Combo1, I want only "ABC" and "DEF" to be be listed in $combo2. How do I implement that?

Link to comment
Share on other sites

Another thing which is now happening now is that now the script stops running once it has run through. And when I did this

Func _populate($computer)
    Global $Services = ObjGet("winmgmts:\\" & $computer & "\root\cimv2")
    Global $ServicesList = $Services.ExecQuery("SELECT * FROM Win32_Service where DisplayName like 'Bluetooth%' ")

It is not even proceeding to stop the services and it is exiting in between. I'm using this now by the way.

For $i = 1 To UBound($sArray) - 1 Step 1
      $service = $sArray[$i - 1]
      RunWait("sc \\" & $computer & " stop "  & $service)
      ProgressSet($i / (UBound($sArray) - 1) * 100, Round($i / (UBound($sArray) - 1) * 100, 0) & "%", "Stopping " & $i & " of " & UBound($sArray) - 1)
   Next
   Sleep(5000)
   ProgressOff()
   _populate()

 

Link to comment
Share on other sites

Can Anyone tell why isn't this working?

Global $Combo1 = GUICtrlCreateCombo("Select Environment", 4, 48, 115, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "123|456|789|0")
Global $Combo2 = GUICtrlCreateCombo("Select Server", 122, 48, 110, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))

Global $cb1 = _GUICtrlComboBox_GetCurSel($Combo1)

Switch $cb1
   Case "123"
      Global $Combo2 = GUICtrlCreateCombo("Select Server", 122, 48, 110, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
      GUICtrlSetData($Combo2, "ABC|DEF")

   #cs
      _GUICtrlComboBox_BeginUpdate($Combo2)
      _GUICtrlComboBox_DeleteAllItems($Combo2)
      GUICtrlSetData($Combo2, "ABC|DEF")
      _GUICtrlComboBox_EndUpdateUpdate($Combo2)
      #ce
   Case "456"
      Global $Combo2 = GUICtrlCreateCombo("Select Server", 122, 48, 110, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
      GUICtrlSetData($Combo2, "GHI|JKL")
      #cs
       _GUICtrlComboBox_BeginUpdate($Combo2)
       _GUICtrlListView_DeleteAllItems($Combo2)
      GUICtrlSetData($Combo2, "GHI|JKL")
      _GUICtrlComboBox_EndUpdateUpdate($Combo2)
      #ce
EndSwitch

 

Link to comment
Share on other sites

6 hours ago, pranaynanda said:

Can Anyone tell why isn't this working?

Global $Combo1 = GUICtrlCreateCombo("Select Environment", 4, 48, 115, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "123|456|789|0")
Global $Combo2 = GUICtrlCreateCombo("Select Server", 122, 48, 110, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))

Global $cb1 = _GUICtrlComboBox_GetCurSel($Combo1)

Switch $cb1
   Case "123"
      Global $Combo2 = GUICtrlCreateCombo("Select Server", 122, 48, 110, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
      GUICtrlSetData($Combo2, "ABC|DEF")

   #cs
      _GUICtrlComboBox_BeginUpdate($Combo2)
      _GUICtrlComboBox_DeleteAllItems($Combo2)
      GUICtrlSetData($Combo2, "ABC|DEF")
      _GUICtrlComboBox_EndUpdateUpdate($Combo2)
      #ce
   Case "456"
      Global $Combo2 = GUICtrlCreateCombo("Select Server", 122, 48, 110, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
      GUICtrlSetData($Combo2, "GHI|JKL")
      #cs
       _GUICtrlComboBox_BeginUpdate($Combo2)
       _GUICtrlListView_DeleteAllItems($Combo2)
      GUICtrlSetData($Combo2, "GHI|JKL")
      _GUICtrlComboBox_EndUpdateUpdate($Combo2)
      #ce
EndSwitch

 

It doesn't work because _GUICtrlComboBox_GetCurSel() retrieve the index of the currently selected item.  In other words instead or retrieving 123, 456, 789 or 0 it will retrieve 0, 1, 2, 3.   You want to use _GUICtrlComboBox_GetEditText() it get the text from the combobox.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

10 hours ago, pranaynanda said:

Alright people, I've got everything working now. I just need the final piece that is a cascading combo box. Please help.

An example script of cascading combo box.

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Create GUI
GUICreate("Example Cascading ComboBox", 400, 296)
$Combo1 = GUICtrlCreateCombo("", 2, 2, 396, 296)
GUICtrlSetData($Combo1, "123|456|789|0")
$Combo2 = GUICtrlCreateCombo("", 2, 30, 396, 296)
GUISetState(@SW_SHOW)

Global $cb1 = _GUICtrlComboBox_GetEditText($Combo1)

Do
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Combo1
            $cb1 = _GUICtrlComboBox_GetEditText($Combo1)

            _GUICtrlComboBox_ResetContent($Combo2)
            If $cb1 = "123" Then GUICtrlSetData($Combo2, "ABC|DEF")
            If $cb1 = "456" Then GUICtrlSetData($Combo2, "GHI|JKL")

        Case $Combo2
            MsgBox($MB_SYSTEMMODAL, 'Information', 'ComboBox Selected Item: ' & _GUICtrlComboBox_GetEditText($Combo2))
    EndSwitch

Until $Msg = $GUI_EVENT_CLOSE
GUIDelete()

 

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Okay, as I said, I'm back. Everything is working nearly fine. I need this to work. I just don't get is how.

_GUICtrlComboBox_BeginUpdate($Combo2)
       _GUICtrlComboBox_ResetContent ($Combo2)
      GUICtrlSetData($Combo2, "GHI|JKL", "Select Server Type")
      _GUICtrlComboBox_EndUpdate($Combo2)

Even though I've set a default value, It is still showing up blank by default when updated. I can see the other entries and the data. I cannot set the combo box to show "Select Server Type" unless any other value is selected from the Combo Box.

Link to comment
Share on other sites

Okay, Now there's another problem. I can't get this to work when i select the machine name from the combo box.

Func _combo2()
               Global $cb2=GUICtrlRead($Combo2)

               Switch $cb2
               Case "ABC"
                      _GUICtrlComboBox_ResetContent ($Combo3)
                     GUICtrlSetData($Combo3, "Select Server|secretmachinename" , 'Select Server')
                     Global $machine=GUICtrlRead($Combo3)
                     ;$machine
                     _populate($machine)
                  Case "DEF"
                     MsgBox(0,"Test","No Server Available")
                  EndSwitch
EndFunc

 

Link to comment
Share on other sites

Okay, now maybe I really have something here to be regarded as a problem.

Func _combo2()
   ;Global $cb2=GUICtrlRead($Combo2)
      If $cb1="Justice League" Then
       Global $cb2=GUICtrlRead($Combo2)
       Switch $cb2

         Case "Batman Servers"
            _GUICtrlComboBox_ResetContent ($Combo3)
            GUICtrlSetData($Combo3, "Select Server|secretservername1|secretservername2" , 'Select Server')

         Case "Superman Servers"
            _GUICtrlComboBox_ResetContent ($Combo3)
            GUICtrlSetData($Combo3, "Select Server|secretservername3|secretservername4|secretservername5" , 'Select Server')

         Case "Wonder Woman Servers"
            _GUICtrlComboBox_ResetContent ($Combo3)
            GUICtrlSetData($Combo3, "Select Server|Secret Server Name 6|secretservername7|secretservername8" , 'Select Server')

         EndSwitch
      ElseIf $cb1="Avengers" Then
         Global $cb2=GUICtrlRead($Combo2)
         Switch $cb2
         Case "Batman Servers"
            _GUICtrlComboBox_ResetContent ($Combo3)
            GUICtrlSetData($Combo3, "Select Server|SecretServerName9|SecretServerName10" , 'Select Server')


EndFunc

Somehow the server types are same in the Justice League and Avengers environment. But actually their server names are different.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...