netbox开启服务后自动访问首页
Dim httpd
Shell.Service.RunService "NBWeb", "NetBox Web Server", "NetBox Http Server Sample"
'---------------------- Service Event ---------------------
Sub OnServiceStart()
Set httpd = NetBox.CreateObject("NetBox.HttpServer")
Set httpd = NetBox.CreateObject("NetBox.HttpServer")
If httpd.Create("", 800) = 0 Then
Set host = httpd.AddHost("", "\wwwroot")
Set host = httpd.AddHost("", "\wwwroot")
host.EnableScript = true
host.AddDefault "index.html"
host.AddDefault "index.html"
httpd.Start
else
Shell.Quit 0
end if
Set ht = CreateObject("NetBox.HtmlWindow")
ht.open " http://localhost/index.html "
ht.showDialog
End Sub
else
Shell.Quit 0
end if
Set ht = CreateObject("NetBox.HtmlWindow")
ht.open " http://localhost/index.html "
ht.showDialog
End Sub
Sub OnServiceStop()
httpd.Close
End Sub
httpd.Close
End Sub
Sub OnServicePause()
httpd.Stop
End Sub
httpd.Stop
End Sub
Sub OnServiceResume()
httpd.Start
End Sub
httpd.Start
End Sub
本文介绍了一种使用NetBox脚本实现服务自动启动并在启动后自动访问首页的方法。通过创建NetBox HttpServer对象并设置相关属性,如启用脚本、添加默认首页等,最后启动服务器并使用HtmlWindow对象打开首页。
24

被折叠的 条评论
为什么被折叠?



