Josette Posted October 29, 2008 Share Posted October 29, 2008 (edited) Usage: Run Main.exe -install To Install Service Then U should Start it in services.msc Run Main.exe -Uninstall To Remove Servies Here is the Main: #include "d:\Au3\UDF\Service.au3" #include <File.au3> $sServiceName = "AppPoolMon" $sServiceDisPlay = "AppPool Monitor" If $cmdline[0] > 0 Then Switch $cmdline[1] Case "-install" InstallService() Case "-uninstall" RemoveService() Case Else ConsoleWrite(" - - - Help - - - " & @CRLF) ConsoleWrite("params : " & @CRLF) ConsoleWrite(" -install : install service" & @CRLF) ConsoleWrite(" -uninstall : remove service" & @CRLF) ConsoleWrite(" - - - - - - - - " & @CRLF) Exit EndSwitch EndIf _Service_init($sServiceName) Func main() $Log = "c:\AppPool.Log" $GateWay = "192.168.1.1" ; Here Is The GateWay,U Should Change It as yours. While 1 Do ProcessClose("dumprep.exe") Until Not ProcessExists("dumprep.exe") ;Kill dumprep.exe Do ProcessClose("dwwin.exe") Until Not ProcessExists("dwwin.exe") ;Kill dwwin.exe Do ProcessClose("drwtsn32.exe") Until Not ProcessExists("drwtsn32.exe") ;Kill drwtsn.exe $time = DllCall("kernel32.dll", "int", "GetTickCount") $T = Int($time[0] / 1000 / 60) ;Get System Runtime If $T > 30 Then $i = "" For $j = 1 To 10 $Ping = Ping($GateWay, 20) If @error Then $i &= 1 Else ExitLoop EndIf Next If $i = "1111111111" Then _FileWriteLog($Log, "Failed On Ping GateWay,Restart .") ShellExecute("shutdown.exe", " -R -F") Sleep(20000) EndIf EndIf $colItems = "" $colItems2 = "" $strComputer = "localhost" $objWMIService = ObjGet("winmgmts:{authenticationLevel=pktPrivacy}\\" & $strComputer & "\root\microsoftiisv2") $colItems = $objWMIService.ExecQuery("Select * from IIsApplicationPoolSetting") $colItems2 = $objWMIService.ExecQuery("Select * from IIsApplicationPool") For $objItem In $colItems If $objItem.AppPoolState = 4 Then _FileWriteLog($Log, "Auto Start AppPool") For $objItem2 In $colItems2 If $objItem2.name = $objItem.name Then $objItem2.Start() EndIf Next EndIf Next $objWMIService = 0 Sleep(60000) WEnd EndFunc ;==>main Func InstallService() ConsoleWrite("Installing service, please wait" & @CRLF) _Service_Create("", $sServiceName, $sServiceDisPlay, '"' & @ScriptFullPath & '"') If @error Then ConsoleWrite("Problem installing service, Error number is " & @error & @CRLF & " message : " & _WinAPI_GetLastErrorMessage()) Else ConsoleWrite("Installation of service successful") EndIf Exit EndFunc ;==>InstallService Func RemoveService() _StopService("", $sServiceName) _DeleteService("", $sServiceName) If Not @error Then ConsoleWrite("service removed successfully" & @CRLF) Exit EndFunc ;==>RemoveService Here is the UDF Service.au3 service.au3 Edited October 29, 2008 by Josette 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