Jump to content
Sign in to follow this  
meganwebb

Refresh Windows Service Status Automatically?

Recommended Posts

meganwebb

I have a program that I created that when the user selects a specific server name, they can choose to reboot that server, check the status of a windows service, restart the windows service, etc. I am using a list view for the server names and then when the user clicks on a server name and then selects the button for one of the options (stop, start, reboot, status, etc), it an array will be used to identify the server name and carry out the request.

For the service status, I would like it to be dynamic to where it will update as the service status updates but I am having problems with my current code because I am using a loop and the status is updating so fast and it appears to be in a constant loop to where I cannot select any of the other options. I tried to put the sleep function in so that the refresh rate was not so rapid, but that didn't work either. I think my problem is that the function is called from a case statement and I don't know how to quanitify when this function should launch. Right now, I have it being launched when case $msg = 0, but that is why it is refreshing so often. Any ideas?

Func ServiceStatusQuery()
If GUICtrlRead(GUICtrlRead($listview2)) = "0" Then; Identifies what server was selected
Else
$arrayServer = StringSplit(GUICtrlRead(GUICtrlRead($listview2)), "|")
                    
$listview3 = GUICtrlCreateListView("                 ", 340, 300, 75, 35, $LVS_NOCOLUMNHEADER)
$servicestatus = _ServiceStatus("FirstNetThinClient", $arrayserver[1])
GUICtrlCreateListViewItem($servicestatus, $listview3)
;sleep (1000)
;sleep (10)

EndIf
EndFunc

Share this post


Link to post
Share on other sites
PsaltyDS

I have a program that I created that when the user selects a specific server name, they can choose to reboot that server, check the status of a windows service, restart the windows service, etc. I am using a list view for the server names and then when the user clicks on a server name and then selects the button for one of the options (stop, start, reboot, status, etc), it an array will be used to identify the server name and carry out the request.

For the service status, I would like it to be dynamic to where it will update as the service status updates but I am having problems with my current code because I am using a loop and the status is updating so fast and it appears to be in a constant loop to where I cannot select any of the other options. I tried to put the sleep function in so that the refresh rate was not so rapid, but that didn't work either. I think my problem is that the function is called from a case statement and I don't know how to quanitify when this function should launch. Right now, I have it being launched when case $msg = 0, but that is why it is refreshing so often. Any ideas?

When there has been no activity, GuiGetMsg() returns 0. So you typically get very many $msg = 0 for each message of interest. That's normal, so don't use it to trigger an action you don't want happening constantly.

Func ServiceStatusQuery()
If GUICtrlRead(GUICtrlRead($listview2)) = "0" Then; Identifies what server was selected
Else
$arrayServer = StringSplit(GUICtrlRead(GUICtrlRead($listview2)), "|")
                    
$listview3 = GUICtrlCreateListView("                 ", 340, 300, 75, 35, $LVS_NOCOLUMNHEADER)
$servicestatus = _ServiceStatus("FirstNetThinClient", $arrayserver[1])
GUICtrlCreateListViewItem($servicestatus, $listview3)
;sleep (1000)
;sleep (10)

EndIf
EndFunc
What the heck is THIS...?!
$arrayServer = StringSplit(GUICtrlRead(GUICtrlRead($listview2)), "|")

Reading the control $listview2 is going to give you the ControlID of another list view?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.