As we all know, it is impossible to restart the server by using ASP directly. At this time, we need to create a component to implement the function. ASP calls the system API through this component, and then operates according to different restart and shutdown methods!
Let’s talk about the production of COM first, and build a new project in VB, of course it’s from AceiveX dll.
1) First modify the project properties, change the project name to system in the project properties window, change the module name to contrast in the class module window, and save the project;
2) Then add a module to declare the API and constants to be used. The following is the content in the module.
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
3) Enter the following code in the class module:
Public Function reboot(atype As Variant) t& = ExitWindowsEx(1, atype) End Function
This function needs to pass a parameter to control the startup method. This parameter is passed from the ASP program. You can see the specific usage method later!
After writing the above code, save the project and compile the project into. Here is the ASP program:
The code in ASP is very simple:
<% atype=request("atype") set sys= ("") (atype) %>
Among them, atype can use 0, 1, 2, 4, 0, 1 and 4.Shut down, 2 forRestart, just execute ASP after writing.
The above is how to create an ASP script component to restart the server. I hope it will be helpful to everyone's learning.