Server application automatically restarts IIS batch processing original

Source: Internet
Author: User

For some reason, the website fails for a period of time, and IIS restarts and returns to normal.
If this happens once or twice, the worst thing is that it happens every day. You cannot fight against IIS every day.
If you want to be lazy, you have to use your brains to find a batch.

Imagine: Write a batch, restart IIS once every hour, and run 24 times.
In a task plan, this batch is run once a day.

Technical Reserves:
IIS restart doscommand: iisreset/restart
Delayed command: Create a. vbs file and enter the command wscript. Sleep (20000) in the file)
Call the. vbs file in DOS: cscript S. vbs
Loop command: For/L % variable in (START, step, end) do command [command-parameters]


Create a. vbs file, such as S. vbs.
**************************************** *********
Wscript. Sleep (3600000)
**************************************** *********

Note: wscript. Sleep (1000) indicates a delay of 1 second.

Create a. BAT file, such as A. bat
For/L % A in (1, 1, 24) Do (
Cscript // nologo S. vbs

Note: For/L % A in (, 24) Do indicates that the loop is executed 24 times.
Cscript // nologo S. vbs indicates that the S. vbs file is called and executed. // nologo indicates that the logo version information is not displayed, without this parameter
Or not.ProgramRun
By feng1725

In fact, the Windows built-in scheduled task can meet the hourly task requirements.
Create a scheduled task, right-click the task, and choose schedule> advanced.
Set start date check repeated tasks set the duration of every × hours × days
Create a. BAT file, such as A. bat


Note: If the scheduled task fails to be started, you can view the log to find the cause.

Check the logs of the "Task Scheduler"
The "Task Scheduler" maintains a log file schedlgu.txt in the % SystemRoot % folder (usually C: \ Windows. You can view logs in the task scheduler window by clicking advanced (menu bar) and then clicking View logs.

The size of a log file is 32 KB. When the maximum size of a log file is reached, it automatically records new information from the beginning of the file and overwrites the information of the old log file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.