1 Dim httpd1,httpd2
2
3 Shell.Service.RunService "NBWeb", "多个虚拟目录", "多个访问端口"
4
5 '---------------------- Service Event ---------------------
6
7 Sub OnServiceStart()
8
9 Set httpd1 = NetBox.CreateObject("NetBox.HttpServer")
10
11 Set httpd2 = NetBox.CreateObject("NetBox.HttpServer")
12
13 If httpd1.Create("127.0.0.1", 80) = 0 Then
14
15 Set host1 = httpd1.AddHost("", "\wwwroot")
16
17 host1.EnableScript = true '允许执行脚本程序(即ASP文件,否则只能访问HTM文件)
18
19 host1.EnableBrowse = true '开启目录浏览
20
21 host1.EnableDebug = false '关闭运行的代码出现运行错误时自动激活系统中的调试环境
22
23 host1.EnableWrite =false '设为可读写的状态
24
25 host1.AddDefault "default.asp"
26
27 host1.AddDefault "default.htm"
28
29 host1.AddDefault "default.html"
30
31 host1.AddDefault "index.asp"
32
33 host1.AddDefault "index.htm"
34
35 host1.AddDefault "index.html"
36
37 'httpd.Start
38
39 else
40
41 Shell.MsgBox "服务器启动失败,80端口可能被占用!请停止当前WEB服务器或用记事本打开serv.box文件修改端口.","错误提示"
42
43 Shell.Quit 0
44
45 end if
46
47 'Set httpd = NetBox.CreateObject("NetBox.HttpServer")
48
49 If httpd2.Create("192.168.0.235", 81) = 0 Then
50
51 Set host2 = httpd2.AddHost("", "aspserver")
52
53 host2.EnableScript = true '允许执行脚本程序(即ASP文件,否则只能访问HTM文件)
54
55 host2.EnableBrowse = true '开启目录浏览
56
57 host2.EnableDebug = false '关闭运行的代码出现运行错误时自动激活系统中的调试环境
58
59 host2.EnableWrite =false '设为可读写的状态
60
61 host2.AddDefault "default.asp"
62
63 host2.AddDefault "default.htm"
64
65 host2.AddDefault "default.html"
66
67 host2.AddDefault "index.asp"
68
69 host2.AddDefault "index.htm"
70
71 host2.AddDefault "index.html"
72
73 httpd1.Start
74
75 httpd2.start
76
77 else
78
79 Shell.MsgBox "服务器启动失败,81端口可能被占用!请停止当前WEB服务器或用记事本打开serv.box文件修改端口.","错误提示"
80
81 Shell.Quit 0
82
83 end if
84
85 End Sub
86
87 Sub OnServiceStop()
88
89 httpd1.Close
90
91 httpd2.Close
92
93 End Sub
94
95 Sub OnServicePause()
96
97 httpd1.Stop
98
99 httpd2.Stop
100
101 End Sub
102
103 Sub OnServiceResume()
104
105 httpd1.Start
106
107 httpd2.Start
108
109 End Sub
2
3 Shell.Service.RunService "NBWeb", "多个虚拟目录", "多个访问端口"
4
5 '---------------------- Service Event ---------------------
6
7 Sub OnServiceStart()
8
9 Set httpd1 = NetBox.CreateObject("NetBox.HttpServer")
10
11 Set httpd2 = NetBox.CreateObject("NetBox.HttpServer")
12
13 If httpd1.Create("127.0.0.1", 80) = 0 Then
14
15 Set host1 = httpd1.AddHost("", "\wwwroot")
16
17 host1.EnableScript = true '允许执行脚本程序(即ASP文件,否则只能访问HTM文件)
18
19 host1.EnableBrowse = true '开启目录浏览
20
21 host1.EnableDebug = false '关闭运行的代码出现运行错误时自动激活系统中的调试环境
22
23 host1.EnableWrite =false '设为可读写的状态
24
25 host1.AddDefault "default.asp"
26
27 host1.AddDefault "default.htm"
28
29 host1.AddDefault "default.html"
30
31 host1.AddDefault "index.asp"
32
33 host1.AddDefault "index.htm"
34
35 host1.AddDefault "index.html"
36
37 'httpd.Start
38
39 else
40
41 Shell.MsgBox "服务器启动失败,80端口可能被占用!请停止当前WEB服务器或用记事本打开serv.box文件修改端口.","错误提示"
42
43 Shell.Quit 0
44
45 end if
46
47 'Set httpd = NetBox.CreateObject("NetBox.HttpServer")
48
49 If httpd2.Create("192.168.0.235", 81) = 0 Then
50
51 Set host2 = httpd2.AddHost("", "aspserver")
52
53 host2.EnableScript = true '允许执行脚本程序(即ASP文件,否则只能访问HTM文件)
54
55 host2.EnableBrowse = true '开启目录浏览
56
57 host2.EnableDebug = false '关闭运行的代码出现运行错误时自动激活系统中的调试环境
58
59 host2.EnableWrite =false '设为可读写的状态
60
61 host2.AddDefault "default.asp"
62
63 host2.AddDefault "default.htm"
64
65 host2.AddDefault "default.html"
66
67 host2.AddDefault "index.asp"
68
69 host2.AddDefault "index.htm"
70
71 host2.AddDefault "index.html"
72
73 httpd1.Start
74
75 httpd2.start
76
77 else
78
79 Shell.MsgBox "服务器启动失败,81端口可能被占用!请停止当前WEB服务器或用记事本打开serv.box文件修改端口.","错误提示"
80
81 Shell.Quit 0
82
83 end if
84
85 End Sub
86
87 Sub OnServiceStop()
88
89 httpd1.Close
90
91 httpd2.Close
92
93 End Sub
94
95 Sub OnServicePause()
96
97 httpd1.Stop
98
99 httpd2.Stop
100
101 End Sub
102
103 Sub OnServiceResume()
104
105 httpd1.Start
106
107 httpd2.Start
108
109 End Sub