1. Write the DCOM component: Suppose we want to remotely start the DNS service through the ASP page, and the DNS server and the Web server are not the same machine. We can compile an ActiveX DLL to implement this function.
First, create a batch file startdns. bat, which is written to the file: Net start DNS. Save the file to a directory on the DNS server, for example, C:/mandns /:
Next, we compile the DLL program as follows (written in VB ):
Public Function startdns () as Boolean
On Error goto errhandle
Dim strreturn = shell ("C:/mandns/startdns. Bat ")
Startdns = true
Exit function errhandle: startdns = false
End Function
DLL name: mandns Class Name: dnsclass we save this DLL under C:/mandns.
2. register the DCOM component:
After compiling the DLL program, we need to register it on the server.
First, open Microsoft Transaction Server on the DNS server, click computers, then click my computer, select packages installed, right-click, select new, and click package. The package wizard is displayed. Select the empty package and name it "mandns". OK. Open this package, select component, right-click, and select new ---> component. Click Import component that are already and select mandns. dll from the list box.
Then open Microsoft Transaction Server on the Web server, click computers, click Remote Computer, select the mandns component on the DNS server, and click OK to add it to the web server.
3. Call the DCOM component:
Compile startdns. asp and call the registered DCOM component. The program is as follows:
<%@ Language = "VBScript" %>
<HTML>
<Head>
<Title>
Start DNS page
</Title>
<Head>
<Body>
<H1> click a button to start the DNS Service
<%
If request. Form ("click") <> "" then
Dim startdns, renstart
Set startdns = server. Createobject ("startdns. dnsclass ")
Renstart = startdns. startdns
If renstart then
Response. Write "DNS service started successfully ."
Else
Response. Write "DNS Service startup failed ."
End if
End if
%>
<Form action = "startdns. asp" method = "Post">
<Input type = submit name = submit value = "start DNS">
<Input type = hidden name = click value = "click">
</Form>
</Body>
</Html>
Programmers can use familiar programming tools to compile ActiveX DLL, use MTS for management, and use ASP programs to reasonably build various components into a system, almost omnipotent functions can be implemented on the Internet.