动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   VBScript → 阅读文章

 VBScript来控制ICF的启动

作者来源: 
阅读 数 222 人次 , 2006-4-3 0:01:00 


option explicit

dim icssc_default, connection_public, connection_private, connection_all
dim netsharingmanager
dim publicconnection, privateconnection
dim everyconnectioncollection

dim objargs
dim con

icssc_default = 0
connection_public = 0
connection_private = 1
connection_all = 2

main( )

sub main( )
if initialize() = true then
getconnectionobjects()
firewalltestbyname(con)
end if
end sub

sub firewalltestbyname(conname)
on error resume next
dim item
dim everyconnection
dim objncprops
dim szmsg
dim bfound
bfound = false
for each item in everyconnectioncollection
set everyconnection = netsharingmanager.inetsharingconfigurationforinetconnection(item)
set objncprops = netsharingmanager.netconnectionprops(item)
bfound = true
everyconnection.enableinternetfirewall
next
end sub

function initialize()
dim breturn
breturn = false
set netsharingmanager = wscript.createobject("hnetcfg.hnetshare.1")
if (isobject(netsharingmanager)) = false then
wscript.echo("unable to get the hnetcfg.hnetshare.1 object")
else
if (isnull(netsharingmanager.sharinginstalled) = true) then
wscript.echo("sharing isn't available on this platform.")
else
breturn = true
end if
end if
initialize = breturn
end function

function getconnectionobjects()
dim breturn
dim item

breturn = true

if getconnection(connection_public) = false then
breturn = false
end if

if getconnection(connection_private) = false then
breturn = false
end if

if getconnection(connection_all) = false then
breturn = false
end if

getconnectionobjects = breturn

end function

function getconnection(connection_type)
dim breturn
dim connection
dim item
breturn = true

if (connection_public = connection_type) then
set connection = netsharingmanager.enumpublicconnections(icssc_default)
if (connection.count > 0) and (connection.count < 2) then
for each item in connection
set publicconnection = netsharingmanager.inetsharingconfigurationforinetconnection(item)
next
else
breturn = false
end if
elseif (connection_private = connection_type) then
set connection = netsharingmanager.enumprivateconnections(icssc_default)
if (connection.count > 0) and (connection.count < 2) then
for each item in connection
set privateconnection = netsharingmanager.inetsharingconfigurationforinetconnection(item)
next
else
breturn = false
end if
elseif (connection_all = connection_type) then
set connection = netsharingmanager.enumeveryconnection
if (connection.count > 0) then
set everyconnectioncollection = connection
else
breturn = false
end if
else
breturn = false
end if

if (true = breturn) then

if (connection.count = 0) then
wscript.echo("no " + cstr(convertconnectiontypetostring(connection_type)) + " connections exist (connection.count gave us 0)")
breturn = false
elseif (connection.count > 1) and (connection_all <> connection_type) then
wscript.echo("error: there was more than one " + convertconnectiontypetostring(connection_type) + " connection (" + cstr(connection.count) + ")")
breturn = false
end if
end if
getconnection = breturn
end function

function convertconnectiontypetostring(connectionid)
dim connectionstring

if (connectionid = connection_public) then
connectionstring = "public"
elseif (connectionid = connection_private) then
connectionstring = "private"
elseif (connectionid = connection_all) then
connectionstring = "all"
else
connectionstring = "unknown: " + cstr(connectionid)
end if

convertconnectiontypetostring = connectionstring
end function

 本文Tags组网  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:VBScript-to-JavaScript Functions
· 下一篇:VBScript的扫描进度条程序
· VBScript Len 函数
· VBScript With 语句
· VBScript Asc 函数
· VBScript 特性
· VBScript CSng 函数


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077