找回密码
 加入
搜索
查看: 1823|回复: 4

用AutoIT能不能做出ICS共享网络的软件?

[复制链接]
发表于 2009-10-20 20:41:45 | 显示全部楼层 |阅读模式
本帖最后由 ajian55 于 2009-11-14 15:20 编辑

如题,能不能用AutoIT做出ICS共享网络的软件?请教高手。
发表于 2009-11-2 16:40:36 | 显示全部楼层
没试过,可以研究下
发表于 2010-4-6 01:45:54 | 显示全部楼层
不知道~~~帮顶!!!!
发表于 2010-7-29 21:19:02 | 显示全部楼层
考大家分错别字
发表于 2010-8-10 23:00:50 | 显示全部楼层
可以,参考VBS脚本
Option Explicit
On Error Resume Next

' *** Configuration Option
'        0 - Only check ICS status on all interfaces
'        1 - Disable if ICS is Enabled on any interface
Const DISABLE_ICS = 1

' *****************************************************************************
' Function    - CheckPerInterfaceICSSetting
' Description - Checks the ICS setting on each of the interfaces and if
'               it is Enabled and DISABLE_ICS = 1, diables it.
'               Note: Disabling ICS on an interface require Admin privileges
' Returns     - Exits from the script with the following errorlevel
'               0 - If ICS is disabled on all the interfaces
'               1 - If ICS is enabled on any interface
'               2 - If unable to query ICS setting on interface due to
'                   COM object not being initialized etc.
'               3 - If unable to disabled ICS on any interface
' ****************************************************************************
Sub CheckPerInterfaceICSSetting()
    On Error Resume Next
    Dim objShare
    Dim objEveryColl
    Dim objShell
   
    Set objShare = Wscript.CreateObject("HNetCfg.HNetShare")
    If (IsObject(objShare) = FALSE ) Then
       WScript.Echo("Unable to create object : HNetCfg.HNetShare")
       WScript.Quit (2)
    End If
   
    Set objEveryColl = objShare.EnumEveryConnection
    If (IsObject(objEveryColl) = FALSE) Then
       WScript.Echo("Unable to Enumerate Connections")
       WScript.Quit (2)
    END IF
   
    Dim objNetConn
    For each objNetConn in objEveryColl
       Dim objShareCfg, ConnectionProps

       Set objShareCfg = objShare.INetSharingConfigurationForINetConnection(objNetConn)
       If (IsObject(objShareCfg) = FALSE) Then
          WScript.Echo("Unable to retrieve Sharing Cfg Object")
          WScript.Quit (2)
       End If
      
       Set ConnectionProps = objShare.NetConnectionProps(objNetConn)
       If (IsObject(ConnectionProps) = FALSE) Then
          WSCript.Echo("Unable to retrieve ConnectionProps object")
          WScript.Quit (2)
       End If

       WScript.Echo "Connection : " & ConnectionProps.Name
       If (objShareCfg.SharingEnabled) Then
          WScript.Echo("ICS is Enabled on this Interface")
          
          'Disable Connection Sharing on this interface if configured to do so
          If (DISABLE_ICS = 1) Then
             DisableICS(objShareCfg)
          Else
             WScript.Echo("Connection Sharing is Enabled on a interface. Validation Failed")
             WScript.Quit (1)
          End If       
       Else
          WScript.Echo("ICS is Disabled on this Interface")
       End If
    Next

    Set objShare = Nothing
    Set objEveryColl = Nothing
    Set objShell = Nothing

    WScript.Echo("Connection Sharing is Disabled on all interfaces. Validation Passed")
    WScript.Quit (0)
End Sub


' *****************************************************************************
' Function    - DisableICS
' Description - Checks for Admin privileges and Disables ICS on the interface
'               passed
' Returns     - Nothing
' ****************************************************************************
Sub DisableICS(objShareCfg)
    On Error Resume Next

    WScript.Echo("Disabling Connection Sharing...")
    objShareCfg.DisableSharing
   
    If (Err.Number <> 0) Then
       WScript.Echo("Unable to Disable ICS on the Interface")
       WSCript.Quit (3)
    End If
End Sub


' *****************************************************************************
' Function    - Main
' Description - Invokes routines to validate the ICS setting on all the interfaces
' Returns    - Nothing
' ****************************************************************************
Sub Main()
    CheckPerInterfaceICSSetting()
End Sub

Main()
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-3 12:28 , Processed in 0.089849 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表