strFullName = WScript.FullName
strWshHost = Right(strFullName, 11)
WScript.Echo "Default script host: " & strWshHost
If strWshHost = "WScript.exe" Then
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /k ""cscript //B //h:cscript&&cscript IISM.vbs""", HIDE_WINDOW, TRUE
If Err.Number <> 0 Then
WScript.Echo "Error 0x" & hex(Err.Number) & " occurred. " & Err.Description & ". " & VbCrLf & "Could not temporarily change the default script host to Cscript."
Err.Clear
WScript.Quit
End If
WScript.Quit
End If
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Security)}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from __instancecreationevent where " _
& "TargetInstance isa 'Win32_NTLogEvent' " _
& "and TargetInstance.EventCode = '213' ")
Wscript.Echo "Monitoring IIS start at : " & now
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo "Restart IIS : " & now
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%COMSPEC% /c IISRESET.exe",,1
whichfile=("C:\apps\iisresetlog.htm")
set fso=createobject("Scripting.FileSystemObject")
if Not fso.FileExists(whichfile) then
iomode=2 : create=true
else
iomode=8 : create=false
end if
set MyFile = fso.OpenTextFile(whichfile,iomode,create)
MyFile.WriteLine "IIS Restart at : " & now & " successfully."
MyFile.Close
set fso=nothing
Loop
Bookmark this post:
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
0 评论:
发表评论