I believe everyone knows that it is impossible to directly restart the server using ASP. At this time, we need to create a component to implement this function. ASP can call the system API through this component, and then restart and shut down in different ways. Today, the editor of the Error New Technology Channel will briefly describe the method of ASP script components to realize server restart.
Let’s talk about the production of COM first, and build a new project in VB, of course, 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 system.dll. Here is the ASP program:
The code in ASP is very simple:
<%atype=request("atype")set sys=server.CreateObject ("system.contral")sys.reboot(atype)%>Among them, atype can be used to use 0, 1, 2, 4, 0, 1 and 4 as shutdown , 2 is used to restart , and execute ASP after writing.
The above is a brief description of the method of ASP script components to realize server restart. I hope it will be helpful to everyone's learning, and I hope everyone will continue to support the wrong new technology channel!