We know that the direct use of ASP is not enough to restart the server, then we need to make a component to implement the function, ASP through this component calls the system API, and then according to different restart and shutdown mode to operate!
The following first said the production of COM, in VB, a new project, of course, is Aceivex DLL.
1) First modify the engineering properties, in the Project Properties window to change the project name to system, in the class Module window to change the module name to Contral, save the project;
2 then add a module that declares the APIs and constants that need to be used, and the following are the contents of 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 in a parameter, used to control the startup mode, this parameter is passed from the ASP program, wait a moment to see the concrete use Method!
Write the above code, save the project, compile the project into System.dll. The following is written in ASP program:
The code in ASP is very simple:
<%
atype=request ("Atype")
set Sys=server. CreateObject ("System.contral")
sys.reboot (atype)
%>
Where atype can use 0, 1, 2, 4,0, 1 and 4 are all shut down , 2 used to restart, after writing ASP can be executed.
The above is the production of an ASP script components to enable the server to restart the implementation of the method, I hope to help you learn.