Juzzz Posted May 30, 2009 Share Posted May 30, 2009 Hi there i jut started today with some COM script. my point was to get the names of my Network adapters + how many there are. are some research i found a script but i don't understand it completely. script: $strFolderName = "Netwerkverbindingen" ; Virtual folder containing icons for the Control Panel applications. (value = 3) Const $ssfCONTROLS = 3 $ShellApp = ObjCreate("Shell.Application") $oControlPanel = $ShellApp.Namespace($ssfCONTROLS) ; Find 'Network connections' control panel item $oNetConnections = "" For $FolderItem In $oControlPanel.Items If $FolderItem.Name = $strFolderName Then $oNetConnections = $FolderItem.GetFolder ExitLoop EndIf Next ;get the adapter names For $oNetConnections In $oNetConnections.Items MsgBox(0, "", $oNetConnections.name) Next i pretty understand it but when i add and msgbox before the ";get the adapter names" code example: MsgBox(0, "", $oNetConnections.Items) i get nothing returned... and even: MsgBox(0, "", $oNetConnections) so how can he do a for statement if there is nothing there? ps. how to now what object names you can use like .items, .name, etc ? thanks. Link to comment Share on other sites More sharing options...
stampy Posted May 30, 2009 Share Posted May 30, 2009 I'm no expert... but your getting a object collection and the message box is only dealing with a string. Here is another bit of code using wmi if your on xp or newer: $objWMIService = ObjGet("winmgmts:\root\cimv2") $colNetCards = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration") For $objNetCard in $colNetCards MsgBox(0,'',$objnetcard.description) Next To know an objects methods, properties etc. you need to look outside of autoit into the object. MSDN is a good source for many of the windows objects. Link to comment Share on other sites More sharing options...
Juzzz Posted May 30, 2009 Author Share Posted May 30, 2009 (edited) Thanks, my code now: $strFolderName = "Netwerkverbindingen" ; Virtual folder containing icons for the Control Panel applications. (value = 3) Const $ssfCONTROLS = 3 $ShellApp = ObjCreate("Shell.Application") $oControlPanel = $ShellApp.Namespace($ssfCONTROLS) ; Find 'Network connections' control panel item $oNetConnections = "" For $FolderItem In $oControlPanel.Items If $FolderItem.Name = $strFolderName Then $oNetConnections = $FolderItem.GetFolder ExitLoop EndIf Next local $i = 0 local $adaper[100] For $oNetConnections In $oNetConnections.Items $i = $i + 1 $adaper[$i] = $oNetConnections.name Next MsgBox(0, "", $adaper[1] & @cr & $adaper[2] & @cr & $adaper[3]) ps. could not find a lot i need on msdn Edited May 30, 2009 by Juzzz Link to comment Share on other sites More sharing options...
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