Restart IIS service every 2 hours.


Recommended Posts

I've made a bat for restarting IIS and scheduled it to run every 2 hours, (cuz i have to find a solution for an exchange prob, and i use this workaround as temporary solution for the problem)

iisreset.bat

start iisreset

when the schedule starts it popup a LOT of Cmd windows (20-30 Windows) with the path of the script.

Does anyone have any hint?

BTW

Meery Xmas to all

Link to comment
https://www.neowin.net/forum/topic/261514-restart-iis-service-every-2-hours/
Share on other sites

the problem is related to the delivering of e-mail in the Lan, restarting IIS (for Smtp) it will deliver the mail succesfully, until i get to fix this problem(it seems that is related with the AV,,,Trend) i have to restart iis .

The problem now is with the number of cmd windows that pops out when the bat is exeute.

if you are running iis 5 take a look at this

http://www.microsoft.com/downloads/details...&DisplayLang=en

for iis 6 try this vb code (just save it as iisrestart.vbs). change '2142295254' to your server name

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebServer Where Name = " & _
        "'W3SVC/2142295254'")

For Each objItem in colItems
    objItem.Start
Next

if its the smtp portion that is causing you issues, why not just stop and start the smtp service? Why do you need to reset all of IIS?

net stop servicename

net start servicename

or you could use

sc stop servicename

sc start servicename

Or if your really having issues and the service is hanging, why not just set the service to restart on failure - and then kill it every 2 hours?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.