GEOSoft Posted July 16, 2008 Share Posted July 16, 2008 I'm reasonably sure this has been done but I can't find it. I need to get a list of all the computers (by name) connected to a network, without using WMI. I've done it with WMI before but this time I don't want to use that method. Thanks all George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
LarryDalooza Posted July 16, 2008 Share Posted July 16, 2008 runwait, "net view", and StdOutRead? maybe AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
ptrex Posted July 16, 2008 Share Posted July 16, 2008 @GEOSoft Something like this can get you started expandcollapse popup#include<GuiListView.au3> #include<Array.au3> #include<GUIConstantsEx.au3> #include<ListViewConstants.au3> GUICreate("NetView in ListView", 520, 550, 100, 100, -1) ;GUISetBkColor(0x00E0FFFF) ; will change background color $listview = GUICtrlCreateListView("Computer Name|Description|IP Address", 10, 10, 500, 520, Default, $LVS_EX_GRIDLINES) _GUICtrlListView_SetColumnWidth($listview, 2, $LVSCW_AUTOSIZE_USEHEADER) Global $s_Comments[1], $n_IP[1] Global $s_Servernames = Net_View() For $i = 0 To UBound($s_Servernames) - 1 GUICtrlCreateListViewItem($s_Servernames[$i] & '|' & $s_Comments[$i] & '|' & $n_IP[$i], $listview) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit (0) EndSwitch WEnd Func Net_View() Local $s_Buf = '' Local $a_Buf = '' Local $i_Pid = Run(@ComSpec & ' /c net view', '', @SW_HIDE, 2 + 4) While Not @error $s_Buf &= StdoutRead($i_Pid) WEnd Local $netView_Lines = StringSplit($s_Buf, @LF) ReDim $s_Comments[UBound($netView_Lines) ] For $i = 4 To UBound($netView_Lines) - 1 $s_Comments[$i - 4] = StringMid($netView_Lines[$i], 24, 30) Next $a_Buf = StringRegExp($s_Buf, "\\\\([0-9a-zA-Z-_]*)", 3) ; Start at line 3 and match \\ any of these chars "0-9, a-z, A-Z, -, _" ReDim $n_IP[UBound($a_Buf) ] TCPStartup() For $i = 1 TO UBound($a_Buf) -1 $n_IP[$i] = TCPNameToIP($a_Buf[$i]) ; Get IPaddresses Next TCPShutdown ( ) ProcessClose($i_Pid) Return $a_Buf EndFunc ;==>Net_View Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
GEOSoft Posted July 16, 2008 Author Share Posted July 16, 2008 Thanks both of you. That was just too basic. Don't know where my head is at today. I can just Run Net View and parse the StdOut with a RegExp. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted July 16, 2008 Author Share Posted July 16, 2008 (edited) Here is what I ended up with and it works fine. Func _ListComputers() Local $rArray, $Buff, $Pid = Run(@ComSpec & ' /c net view', '', @SW_HIDE, 6) While Not @error $buff &= StdoutRead($Pid) WEnd $rArray = StringRegExp($Buff, "[\\]+([\w-]+)", 3) If @Error Then $rArray = StringRegExp(@ComputerName, "(.+)", 1) Return $rArray EndFunc Edit: mistakingly used quote tags instead of code tags Edited July 16, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
rasim Posted July 17, 2008 Share Posted July 17, 2008 GEOSoftAnother solution Link to comment Share on other sites More sharing options...
GEOSoft Posted July 17, 2008 Author Share Posted July 17, 2008 GEOSoftAnother solutionThat I believe may be the one I was thinking of before. I knew I had seen it. The one I posted is short and simple. However there is still going to be a problem with the application itself. The idea behind getting the Computer names was to be able to enumerate the drives on all the computers and then perform file operations on certain files. That is a bit more difficult to do and I have not been able to get it working yet. I think the script will end up having to be run locally on each computer which means that listing the computers, in this case, was all for naught. Bummer. It's a virus removal tool so It would have been nice to check the whole network at one time. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
coffeeturtle Posted July 25, 2011 Share Posted July 25, 2011 Here is what I ended up with and it works fine. Func _ListComputers() Local $rArray, $Buff, $Pid = Run(@ComSpec & ' /c net view', '', @SW_HIDE, 6) While Not @error $buff &= StdoutRead($Pid) WEnd $rArray = StringRegExp($Buff, "[\\]+([\w-]+)", 3) If @Error Then $rArray = StringRegExp(@ComputerName, "(.+)", 1) Return $rArray EndFunc Edit: mistakingly used quote tags instead of code tags Sorry to bring this thread back from the dead. Could anyone help by telling me how could I use this code (or any like it) to get the output into a combobox or list dropdown to have an end-user select the appropriate computer found on the network? Thank you for your help. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 26, 2011 Author Share Posted July 26, 2011 $aComputers = _ListComputers();; That's the function posted above. $sData = "" For $i = 0 To Ubound($aComputers) -1 $sData &= $aComputers[$i] & "|" Next GuiCtrlSetData($SomeCombobox, StringTrimRight($sData, 1), $aComputers[1]) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
coffeeturtle Posted July 28, 2011 Share Posted July 28, 2011 (edited) $aComputers = _ListComputers();; That's the function posted above. $sData = "" For $i = 0 To Ubound($aComputers) -1 $sData &= $aComputers[$i] & "|" Next GuiCtrlSetData($SomeCombobox, StringTrimRight($sData, 1), $aComputers[1]) Thank you so much for the quick reply! I can't wait to try it out. I'm still trying to learn more about Ubound so I wouldn't have figured this out alone for some time (if ever) . (I'm also trying to learn to recreate .vbs scripts into autoit myself so I can implement wmi better into my code). Thank you again, GeoSoft! Edited July 28, 2011 by coffeeturtle Link to comment Share on other sites More sharing options...
GEOSoft Posted July 28, 2011 Author Share Posted July 28, 2011 Here is a function with a sample Call that you can re-use it without having to duplicate code for several controls GuiCtrlSetData($SomeCombobox, _ArrayToList($aComputers), $aComputers[0]);; Here we are setting the list and making the first computer ([0]) in the array default Func _ArrayToList($a_Array, $i_Ubound = 0) If NOT IsArray($a_Array) Then Return SetError(1,1, "The parameter must be an array") Local $s_Rtn = "", $s_Sep = Opt("GUIDataSeparatorChar") For $i = 0 To $i_Ubound -1 $s_Rtn &= $a_Array[$i] & $s_Sep Next Return (StringTrimRight($s_Rtn, StringLen($s_Sep))) EndFunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
coffeeturtle Posted August 1, 2011 Share Posted August 1, 2011 Here is a function with a sample Call that you can re-use it without having to duplicate code for several controls GuiCtrlSetData($SomeCombobox, _ArrayToList($aComputers), $aComputers[0]);; Here we are setting the list and making the first computer ([0]) in the array default Func _ArrayToList($a_Array, $i_Ubound = 0) If NOT IsArray($a_Array) Then Return SetError(1,1, "The parameter must be an array") Local $s_Rtn = "", $s_Sep = Opt("GUIDataSeparatorChar") For $i = 0 To $i_Ubound -1 $s_Rtn &= $a_Array[$i] & $s_Sep Next Return (StringTrimRight($s_Rtn, StringLen($s_Sep))) EndFunc Thank you again GeoSoft. That is very kind of you! I've just gotten back so I will be using this right away (and learn a few things in the process). 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