网站建设| 数据库类| 图形图象| 程序设计| 现代办公| 操作系统| 考试认证| 网络技术| 软件工程| 电脑相关| 文学作品
网站开发| 网页制作| 操作系统| 图象图形| 考试认证| 数据库类| 程序设计| 硬件技术| 现代办公| 网络技术| 笑话频道
 
您的位置: 电脑书库首页-> 电脑文摘-> 网站开发-> 其它-> 用VBScript来控制ICF的启动

用VBScript来控制ICF的启动
作者:佚名 来源:InterNet 加入时间:2005-4-4
相关文章
  • 妙用VBScript自制IE工具栏按钮
  • PHP, JScript和VBScript函数和类的语法
  • vbscript错误代码及对应解释大全
  • VBScript函数补习课
  • VBScript 函数集
  • 一个显示Grid的VBScript对象
  • 用VBScript实现对Windows注册表的修改
  • VBScript的扫描进度条程序
  • VBScript-to-JavaScript Functions
  • 什么是VBScript
  • 相关书籍:
  • VBScript语言参考
  • VBScript函数速查手册
  • VBScript5.5脚本语言参考
  • 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


    [文章录入员:nancy]

    相关文章
  • 妙用VBScript自制IE工具栏按钮
  • PHP, JScript和VBScript函数和类的语法
  • vbscript错误代码及对应解释大全
  • VBScript函数补习课
  • VBScript 函数集
  • 一个显示Grid的VBScript对象
  • 用VBScript实现对Windows注册表的修改
  • VBScript的扫描进度条程序
  • VBScript-to-JavaScript Functions
  • 什么是VBScript
  • 相关书籍:
  • VBScript语言参考
  • VBScript函数速查手册
  • VBScript5.5脚本语言参考
  • 本站推荐内容

    近期主机类热搜关键词:
    美国服务器 美国服务器租用 海外服务器租用 国外服务器租用

    其它
    ASP/ASP.NET
    PHP技术
    JSP技术
    XML技术
    CGI/PERL
    WEB服务器
    WordPress专题
    其它
    电脑教程阅读排行
    ·VBScript 函数集
    ·关于SQL语句中的引号问题(VB...
    ·网站建设步骤
    ·网上建站论坛的选择和安装(菜鸟版...
    ·用ASP动态生成JavaScri...
    ·Apache+PHP+MySQL...
    ·用VBScript实现对Wind...
    ·VBScript和JavaScr...
    ·在javascript中调用vb...
    ·一个简单的javascript菜...