iceberg Posted July 14, 2008 Share Posted July 14, 2008 hi guys, appreciate if the following script could be simplified. and also, need some advice as to why line 25 doesn't work. thanks. expandcollapse popup#include <ServiceControl.au3> Global $sServiceName, $State Global $sComputerName = "." Global $ini = @ScriptDir & "\settings.ini" Global $svc = IniReadSection($ini, "services") Dim $nRet $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" For $p = 1 To $svc[0][0] $sServiceName = $svc[$p][0] Exists() Next Func Exists() $nRet = _ServiceExists($sComputerName, $sServiceName) If $nRet Then $objWMIService = ObjGet("winmgmts:\\" & $sComputerName & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("Select * from Win32_Service where displayname = '" & $sServiceName & "'", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) For $objItem In $colItems $State = $objItem.State IniWrite($ini, "services", $sServiceName, $State) If $State <> "Running" Then Page() Next Else Page2() EndIf EndFunc ;==>Exists Func Page() $page = IniReadSection($ini, "PageList") For $i = 1 To $page[0][0] MsgBox(4096, "Paging " & $page[$i][1], @ComputerName & ": " & $sServiceName & " " & $State) Next EndFunc ;==>Page Func Page2() $page = IniReadSection($ini, "PageList") For $j = 1 To $page[0][0] MsgBox(4096, "Paging " & $page[$j][1], @ComputerName & ": " & $sServiceName & " does not exists.") IniWrite($ini, "services", $sServiceName, "NON-EXISTENT") Next EndFunc ;==>Page2 mouse not found....scroll any mouse to continue. 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