;; Change these values to match your environment SET local_site_name = "My Local IIS Managed Site" SET small_file_name = "sitemap.xml" :start ;; Allow 3 failures (per cycle) before taking action. LOOPCOUNT 3 ;; Test downloading a small file from the local website. :test_web_site FTPLOGON local_site_name RCVFILE small_file_name IFERROR= $ERROR_SUCCESS GOTO done ;; If we reached this line the test failed. ;; Wait 30 seconds before trying again. PAUSE /for=30 LOOPTO test_web_site ;; If we reached this line the test failed 3 times. ;; Take action by restarting the WWW service. DOSCMD 'net stop "World Wide Web Publishing Service"' DOSCMD 'net start "World Wide Web Publishing Service"' ;; Reset the failure counter LOOPCOUNT 3 ;; Test again after restarting the WWW service. ;; If it fails 3 more times take action using IISReset. :post_restart_test FTPLOGON local_site_name RCVFILE small_file_name IFERROR= $ERROR_SUCCESS GOTO done PAUSE /for=30 LOOPTO post_restart_test EXEC "iisreset /restart" /timeout=120 :done FTPLOGOFF ;; Wait 5 minutes (300 seconds) between cycles PAUSE /for=300 GOTO start