Matrix112 Posted July 9, 2006 Posted July 9, 2006 (edited) Hi, i want to write a script that can switch ics on and off for my internet connection. I searched but cant find a dll or an Objekt for doing this. I tried to find a reg key with regmon. I set the filter to explorer.exe but i get a mass of reads and writes. Does somone know how to do this? Edited July 10, 2006 by Matrix112
Moderators big_daddy Posted July 10, 2006 Moderators Posted July 10, 2006 (edited) I can't test it, but this should work: expandcollapse popup_EnableDisableICS("YourConnectionName", True) ; true enables, false disables Func _EnableDisableICS($sConnectionName, $bEnable) Local $bFound = False $oNetSharingManager = ObjCreate("HNetCfg.HNetShare.1") If Not IsObj($oNetSharingManager) Then MsgBox(48, "Error", "Unable to get the HNetCfg.HnetShare.1 object.") Exit EndIf If Not $oNetSharingManager.SharingInstalled Then MsgBox(48, "Error", "Sharing is not available on this platform.") Exit EndIf $oConnectionCollection = $oNetSharingManager.EnumEveryConnection For $oItem In $oConnectionCollection $EveryConnection = $oNetSharingManager.INetSharingConfigurationForINetConnection ($oItem) $objNCProps = $oNetSharingManager.NetConnectionProps ($oItem) If $objNCProps.name = $sConnectionName Then $bFound = True MsgBox(0, "Info", "Setting ICS to " & $bEnable & " on connection: " & $objNCProps.name) If $bEnable Then $EveryConnection.EnableSharing (0) Else $EveryConnection.DisableSharing EndIf EndIf Next If Not $bFound Then MsgBox(48, "Error", 'Unable to find the connection "' & $sConnectionName & '"') EndIf EndFunc ;==>_EnableDisableICS Edit: forgot to tidy Edited July 11, 2006 by big_daddy
Matrix112 Posted July 11, 2006 Author Posted July 11, 2006 (edited) Thx for help. I tried it, but get following Autoit Error: The requested action with this object has failed. I searched it in object viewer and found it. But i dont know what is wrong. Edit: Ok i have now recreated internetconnection and it works, but after i get Error from Autoit. $EveryConnection = $oNetSharingManager.INetSharingConfigurationForINetConnection ($oItem) $EveryConnection = $oNetSharingManager.INetSharingConfigurationForINetConnection ($oItem)^ERROR Error: The requested action with this object has failed. Edited July 11, 2006 by Matrix112
Moderators big_daddy Posted July 11, 2006 Moderators Posted July 11, 2006 Thx for help. I tried it, but get following Autoit Error: The requested action with this object has failed.I searched it in object viewer and found it. But i dont know what is wrong.Edit: Ok i have now recreated internetconnection and it works, but after i get Error from Autoit.$EveryConnection = $oNetSharingManager.INetSharingConfigurationForINetConnection ($oItem)$EveryConnection = $oNetSharingManager.INetSharingConfigurationForINetConnection ($oItem)^ERRORError: The requested action with this object has failed.I'm not going to pretend to understand all this script, I just converted it from vb. I tested it lastnight on my pc and it worked without error for me. Make sure you are running the latest beta, and see if that helps.
Matrix112 Posted July 11, 2006 Author Posted July 11, 2006 Ok, now it works thx I removed a unused incomming connection and now it works great
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now