I now have so a example, is I want to monitor a web service of the project, when the service problems, through the VBS testing can automatically restart the service,
Two of my environment, respectively is: Windows 7 64 - bit, Windows server 2003
Symptoms: Run the same VBS program, when the web service problems, automatic restart, and restart Windows 7 will be able to test properly, 2003 also can detect but will not be able to restart operations
The most important is, before 2003 will also be able to run normally, now don't know why is constantly jumping DOS window, (I remember running normally, after I give jinshan drug gangsters did security patches)
VBS code is as follows:
On the error resume Next Dim a A=True Data="https://bbs.csdn.net/topics/restart tomcat8 -- -- -- -- -- -- -- -- -- -- ->" The set WshShell=WScript. CreateObject (" WScript. Shell ") Set the fs=createobject (" scripting. Filesystemobject ") The Do While a Set the HTTP=CreateObject (" Microsoft. XMLHTTP ") HTTP. Open "GET", "http://localhost:8080/oa/system/SysOnline", false HTTP. Send
. If the HTTP Status & gt; Then 299 The set ts=fs. Opentextfile (" c: \ xfgl_ "& amp; Date&" The.txt ", 8, true)
WshShell. Run (" taskkill/F/im Tomcat8. Exe/T ") WshShell. Run (" net start Tomcat8 ")
Ts. The write data Ts. Write "the error code: "Ts. Write HTTP. Status Ts. Write "-- -- -- -- -- -- -- the error time:" Ts. Write now Ts. Writeblanklines 2 Ts. Close End the if WScript. Sleep (1000) Loop
VBS every second visit http://localhost:8080/oa/system/SysOnline page at a time, if the visit is not normal, the HTTP. The Status & gt; 299, then executes WshShell. Run (" taskkill/F/im Tomcat8. Exe/T ") WshShell. Run (" net start Tomcat8 ") these two commands,
big
CodePudding user response:
if the access is not normal, the HTTP Status & gt; 299, then executes WshShell. Run (" taskkill/F/im Tomcat8. Exe/T ") WshShell. Run (" net start Tomcat8 ") these two commands,
.net. Exe and Tomcat8. Exe is a console application! When they run, of course, would jump DOS window,