Jump to content
Sign in to follow this  

Update List View

Recommended Posts


I have some code that will based on a file will try to call the shutdown routines we have installed that are configured for use by APC. Means that we can use the same shutdown routines that also close off a number of running tasks or services cleanly.

The initial list creation is fine and generated in a while loop

At the end, I just use a simple For loop looking at each server that was still pinging and then want to update its entry in the list view

However, it does not do this.

I added the $myArr[$myArrUB][5] at the beginning of the GuiCtrlCreateListViewItem as a au3 I saw showed how to update a listview and was referring to $item1, $item2. Of course I have no idea how many items I will create so I added that as the marker in the array. In doing that it still does not update

For now, I remove the listview and recreate, which while it work it is not pretty and does cause a lot of screen flicker.

The iniail creation of the list view

[font=courier new,courier,monospace]GuiCreate("Status", 650,500,100,200,-1, $listview)[/font]

[font=courier new,courier,monospace]$listview = GUICtrlCreateListView("Target                | Pre Ping      | Launch Status                                    | Program status                         | Post Ping         ", 10,100,730,350,$LVS_REPORT)

[font=courier new,courier,monospace]While 1
Local $newsize = UBound($myarr)+1
ReDim $Myarr[$newsize][6]
local $MyArrUB = UBound($myarr)-1
$string = FileReadLine($infile)
if @error = -1 then ExitLoop
if StringStripWS($string,3) = "" then ExitLoop
$myArr[$MyArrUB][0] = $string[/font]

[font=courier new,courier,monospace] $msg=GUIGetMsg()[/font]
[font=courier new,courier,monospace] GUICtrlCreateLabel("Processing server : "& $string & "                  " ,10,30)
GUICtrlCreateLabel("Attempting to start cleanshutdown"& "                    ", 10,50)[/font]
[font=courier new,courier,monospace] consolewrite ("Attempting to run cleanshutdown on server : " & $string & @LF)
$result = _WMI_Proc_Exec($string,"c:cleanshutdowncleanshutdown.exe")
;$result = _WMI_Proc_Exec($string,"c:cleanshutdownabort.exe")[/font]
[font=courier new,courier,monospace] Local $var = Ping($string, 250)
if $var Then
$PrePing = "Pinging"
$myArr[$MyArrUB][4] = " "
$PrePing = "No Ping"
$myArr[$MyArrUB][4] = "Did not Respond to initial ping"
[font=courier new,courier,monospace] $myArr[$MyArrUB][1] = $PrePing[/font]
[font=courier new,courier,monospace] Switch $result
Case 0
    consolewrite ("Error processing WMI on server : " & $string [email="&@LF"]&@LF[/email])
    $myArr[$MyArrUB][2] = "Error Processing WMI"
    $myArr[$MyArrUB][3] = "Error Processing WMI"[/font]

[font=courier new,courier,monospace] case 1
    $myArr[$MyArrUB][2] = "Processed WMI"
    consolewrite ("Processed WMI on server : " & $string [email="&@LF"]&@LF[/email])
    GUICtrlCreateLabel("Checking status of program on target"& "                     ",10,50)
    $wmicheck = _WMI_Check_Proc($string, "cleanshutdown.exe")
    Switch $wmicheck
     Case 0
     $myArr[$MyArrUB][3] = "Running"
     Case 1
     $myArr[$MyArrUB][3] = "Not Running"
     Case 2
     $myArr[$MyArrUB][3] = "Unable to Process"
case 2
    consolewrite ("Unable to send command to server : " & $string [email="&@LF"]&@LF[/email])
    $myArr[$MyArrUB][3] = "Command not Sent"
[font=courier new,courier,monospace] $myArr[$myArrUB][5] = GuiCtrlCreateListViewItem($myArr[$MyArrUB][0] & " | " & $myArr[$MyArrUB][1] & " | " & $myArr[$MyArrUB][2] & " | " & $myArr[$MyArrUB][3] & " | To be Checked" , $listview)

[font=courier new,courier,monospace]WEnd[/font]

[font=courier new,courier,monospace][font=arial,helvetica,sans-serif][font=courier new,courier,monospace]

And then the code that tries to update

[font=courier new,courier,monospace] Local $var = Ping($myArr[$x][0], 250)
if $var Then
$MyArr[$x][4] = "Pinging"
$MyArr[$x][4] = "Not Pinging"


GUICtrlSetData($Myarr[$x][5],$myArr[$x][0] &"|"& $myArr[$x][1] &"|"& $myArr[$x][2] &"|"& $myArr[$x][3] &"|"& $myArr[$x][4],$listview)[/font]
[font=courier new,courier,monospace]

Any ideas would be appreciated

Edited by poyntzj

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