Home > Software engineering >  About the VBS program is not working
About the VBS program is not working

Time:10-13

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,

CodePudding user response:

reference 1st floor Chen8013 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,


You don't understand what I mean, I mean, I can now pass the VBS program launched normally,

I can only manually on the CMD window in these two commands is valid, and in the inside of the VBS invalid, is constant bounce window (opening and closing, it is not started) and in all my local it is normal,

CodePudding user response:

Using a debugger (OD, WINDBG) debugging service program
To debug the initialization code of a service application, the debugger must be attached when the service is started. This is accomplished by creating a registry key:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Image File Execution Options \ ProgramName


The ProgramName is The image file for The service application you are was debugging. Do not specify a path. For example, The ProgramName took look like MyService. Exe.

Under this key The create a string data value called The Debugger. The value of this string should be set to The full path of The Debugger that will be 2. For example,

C: \ Debuggers \ windbg exe



In addition to setting this registry key, the service application must be marked as "interactive". This allows your service to interact with the desktop, and allows the debugger window to appear on your desktop.

This again requires modifying a registry key, you must bitwise - or the type entry for service with 0 x100 (This is the value for SERVICE_INTERACTIVE_PROCESS "according to Winnt. H). The exact location and the name of This registry entry around the for example:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ MyServiceKey


Finally, you need to adjust the service application timeout. Otherwise, the service application will kill the debugger within 20 seconds after starting, Adjusting the timeout involves setting an entry in the following registry key:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control


Under this key, the create a DWORD data value called ServicesPipeTimeout. Set this entry to the amount of time in milliseconds that want the service to wait before timing out. For example, 60000 is one minute, while 86400000 is 24 hours.

Set to come into force after ServicesPipeTimeout need to restart the system

Now, when the service is started, the debugger will also start. When the debugger starts, it will stop at the initial process breakpoint, before the service has begun running. This allows you to set breakpoints or otherwise configure your debugging session to let you monitor the startup of your service. Another option is to place calls to the DebugBreak function in your service from the point at which you would like to break into the debugger. (For more information, see DebugBreak in the Platform SDK documentation.)

If your service is running with other services in a service Host Process, you may need to isolate the service into its own service Host Process.

CodePudding user response:

CMD command without parentheses can run normally
  • Related