e2e4au Posted March 6, 2006 Share Posted March 6, 2006 Could someone please tell me if you can monitor a windows service. I need to be able to tell if the service is STOPPED or STARTED at any given point in time and then do something depending on the state. Thanks in advance Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 6, 2006 Moderators Share Posted March 6, 2006 Could someone please tell me if you can monitor a windows service.I need to be able to tell if the service is STOPPED or STARTED at anygiven point in time and then do something depending on the state.Thanks in advanceSearch the forum, there was something on this in the last month or so I believe. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
pecloe Posted March 6, 2006 Share Posted March 6, 2006 ;returns 4 if running ;beta only $servicename = 'wuauserv'; example windows updates $stdout = Run('sc.exe query ' & $servicename, '', @SW_HIDE, 2) $data = _StdOut($stdout) Func _StdOut($stdout) Local $data While 1 $data = StdOutRead($stdout) If @error Then Return 'unknown' If $data Then $data = StringStripWS($data, 4) Select Case StringInStr($data, 'STATE : 1') Return '1' Case StringInStr($data, 'STATE : 2') Return '2' Case StringInStr($data, 'STATE : 3') Return '3' Case StringInStr($data, 'STATE : 4') Return 'Running' Case Else Return 'unknown' EndSelect Else Sleep(100) EndIf WEnd EndFunc MsgBox(0, '', $data) i don't know who wrote this code, i did not. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now