We have several servers in the IDC, and each server (window2003 + IIS6) has more than 20 websites. Currently, some customers require 24 hours to activate the website, some customers agree to close the website at the above time. How can this be done manually! Every night when you watch the Olympics, you are worried about shutting down your website. Every morning, you get started earlier than the first day, and remotely log on to the website. After two days of suffering, I finally learned how to enable and disable the website automatically through the communication between google and MVP!
There are two methods:
Solution 1: Permission control automatically switches the website
The website that requires 24 hours of activation is not processed. Put the website that needs to be temporarily closed during the Olympics in a file.
For example, D: websiteest.txt
The batch file is as follows (stop the website)
@ Echo off
For/f "usebackq tokens = *" % a in ("d: websiteest.txt") do (
Echo y | cacls "% a"/d everyone
)
The batch file is as follows (enable the website)
@ Echo off
For/f "usebackq tokens = *" % a in ("d: websiteest.txt") do (
Echo y | cacls "% a"/g everyone: f
)
The erverybody permission is required to access the website. Deleting the erverybody permission directly causes the website to be inaccessible due to insufficient permissions,
In this way, we can achieve our goal. Next we only need to add these two files to the scheduler task.
Solution 2: use scripts provided by IIS
It is difficult to deal with ASP, JSP, And. NET websites with messy locations. So I found a simpler method, using the VBS tool adsutil. vbs that comes with IIS.
The batch file is as follows (stop the website)
C: InetpubAdminScriptsadsutil. vbs STOP_server W3SVC/1237755992
C: InetpubAdminScriptsadsutil. vbs STOP_server W3SVC/1739915248
The batch file is as follows (enable the website)
C: InetpubAdminScriptsadsutil. vbs START_server W3SVC/1237755992
C: InetpubAdminScriptsadsutil. vbs START_server W3SVC/1739915248
Add the above batch processing to the scheduled task. The number following W3SVC/is the website identifier. Hey, it's easy.
However, note that win2003 and win2000 are different. The win2000 method is as follows:
The batch file is as follows (stop the website)
C: InetpubAdminScriptsstopweb. vbs-a 31,32
C: InetpubAdminScriptsstopweb. vbs-a 5, 52
The batch file is as follows (enable the website)
C: InetpubAdminScriptsstartweb. vbs-a 31,32
C: InetpubAdminScriptsstartweb. vbs-a 5, 52
The numbers are also website identifiers. If you do not know what the identifiers are, you can see which folder of the website log storage space W3SVC11. 11 is the identifier of the website. Hey, of course you write a program. That's perfect! More use cases of the adadsutil. vbs script. You can search Baidu or GOOGLE