JeromeB Posted September 28, 2010 Share Posted September 28, 2010 (edited) Hey everyone. At this moment, i have this code, works well, and i would like to add in the list view the computer name return by each Ip Address. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <Array.au3> Global $IpList, $aIpList #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Lookup", 160, 50, 558, 439) $Button1 = GUICtrlCreateButton("Go", 32, 8, 97, 33, $WS_GROUP) $Form2 = GUICreate("Result", 633, 447, 192, 124) $List1 = GUICtrlCreateListView("", 8, 8, 609, 422) _GUICtrlListView_AddColumn($List1, 'IP',200) GUISetState(@SW_SHOW, $Form1) GUISetState(@SW_HIDE, $Form2) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUISetState(@SW_HIDE, $Form1) sleep(1000) GUISetState(@SW_SHOW, $Form2) go() EndSwitch WEnd Func go() ;_GUICtrlListView_DeleteAllItems($List1) If @error Then Return GUICtrlCreateListViewItem('No Result',$List1) For $i = 1 To 30 ConsoleWrite("Ping 192.168.100." & $i & @CRLF) If Ping("192.168.100." & $i, 50) > 0 Then $IpList = "192.168.100." & $i GUICtrlCreateListViewItem($IpList, $List1) EndIf Next EndFunc Thx for your help. Jérôme Edited September 28, 2010 by Jerome60 Link to comment Share on other sites More sharing options...
wakillon Posted September 28, 2010 Share Posted September 28, 2010 See _Tcpiptoname function in helpfile, but i don't know if it works on local network ... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
wakillon Posted September 28, 2010 Share Posted September 28, 2010 (edited) Yes it works on local network ! #include <array.au3> #include <inet.au3> Dim $aResult, $sIp TCPStartup() $sIp = '192.168.0.1' $aResult = _TCPIpToName ($sIp, 1) If @error Then MsgBox(0, "_TCPIpToName()", "@error = " & @error & @LF & "@extended = " & @extended) Else _ArrayDisplay($aResult, "Local Hostname(s)") EndIfit give me my computername ! Edited September 28, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
JeromeB Posted September 28, 2010 Author Share Posted September 28, 2010 Hey Yep its works, thx a lot. But i have an other question, is it possible to return the actually account of Active Directory at this moment who is logon on the computer ? Ty Link to comment Share on other sites More sharing options...
wakillon Posted September 28, 2010 Share Posted September 28, 2010 (edited) HeyYep its works, thx a lot.But i have an other question, is it possible to return the actually account of Active Directory at this moment who is logon on the computer ?Ty Just by the IP, sorry, I don't think so ! Edited September 28, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
JeromeB Posted September 28, 2010 Author Share Posted September 28, 2010 Hey IP and ComputerName ? Is it possible ? If its not possible, there is some other way to find it ? Jérôme Link to comment Share on other sites More sharing options...
LurchMan Posted September 28, 2010 Share Posted September 28, 2010 (edited) Hey IP and ComputerName ? Is it possible ? If its not possible, there is some other way to find it ? Jérôme You can use WMI, the only problem with that is its kinda slow and depends on what network speeds you have. $strComputer = "127.0.0.1" ;Obviously for testing $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strComputer & "\root\cimv2") $colComputers = $objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For $objComputer in $colComputers ConsoleWrite( $objComputer.Name) Next I tested this with a network IP addy and it returned the computer name. Returns Username: $strComputer = "127.0.0.1" ;Obviously for testing $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strComputer & "\root\cimv2") $colComputers = $objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For $objComputer in $colComputers ConsoleWrite( $objComputer.UserName) Next Edited September 28, 2010 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
wakillon Posted September 28, 2010 Share Posted September 28, 2010 See Active Directory UDF Topic, perhaps it can help you... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
JeromeB Posted September 29, 2010 Author Share Posted September 29, 2010 You can use WMI, the only problem with that is its kinda slow and depends on what network speeds you have. $strComputer = "127.0.0.1" ;Obviously for testing $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strComputer & "\root\cimv2") $colComputers = $objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For $objComputer in $colComputers ConsoleWrite( $objComputer.UserName) Next Thx, works well. I have an other question . How can i get back more information about a computer ? Like Space disk free/used, mémory free/used, network drive mapped on the computer... And some other things if you have idea or answer. Thank you. Jérôme Link to comment Share on other sites More sharing options...
LurchMan Posted September 29, 2010 Share Posted September 29, 2010 Thx, works well. I have an other question . How can i get back more information about a computer ? Like Space disk free/used, mémory free/used, network drive mapped on the computer... And some other things if you have idea or answer. Thank you. Jérôme WMI Classes: http://msdn.microsoft.com/en-us/library/aa394084%28v=VS.85%29.aspx For Drive Space look at DriveFreeSpace () and DriveSpaceTotal () in the help file. It doesn't say you can use it for remote computers but I've found you can do it like this: DriveSpaceFree ("\\servername\c$") For Network mapped drives on a remote computer I can't really think of a way to do it off the top of my head. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
JeromeB Posted September 29, 2010 Author Share Posted September 29, 2010 WMI Classes: http://msdn.microsoft.com/en-us/library/aa394084%28v=VS.85%29.aspx For Drive Space look at DriveFreeSpace () and DriveSpaceTotal () in the help file. It doesn't say you can use it for remote computers but I've found you can do it like this: DriveSpaceFree ("\\servername\c$") For Network mapped drives on a remote computer I can't really think of a way to do it off the top of my head. Thx for your reply. I found the function DriveGetDrive, but can i get the information from a computer in my network ? Jérôme Link to comment Share on other sites More sharing options...
NiVZ Posted September 29, 2010 Share Posted September 29, 2010 If you have admin permission you can get the logged in user by looping through the registry HKCU to find which one has a 'Volatile Environment' key (this is only present for the person logged in)You can use the 'full name' or 'username' but I've found the safest way is to StringSplit the HOMEPATH and grab just the last part.NiVZHeyYep its works, thx a lot.But i have an other question, is it possible to return the actually account of Active Directory at this moment who is logon on the computer ?Ty Link to comment Share on other sites More sharing options...
LurchMan Posted September 29, 2010 Share Posted September 29, 2010 Thx for your reply.I found the function DriveGetDrive, but can i get the information from a computer in my network ? JérômeNot that I know of. I've done a little bit of R&D with WMI and can't find an easy and quick solution either. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
JeromeB Posted September 29, 2010 Author Share Posted September 29, 2010 (edited) Ok thx for your reply. i'm waiting an answer if someone know how to get by DriveGetDrive in network computer the drive map. Or if there is any other way to get the HDD and network drive on network computer, i take it. Edit : I did this, but works only on my computer, i dont get network drive from other computer but just HDD. $IpList = "127.0.0.1" Dim $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $IpList & "\root\cimv2") Dim $colDrives = $objWMIService.ExecQuery _ ("Select * From Win32_LogicalDisk") For $objDrive in $colDrives MsgBox("", "", "Drive letter: " & $objDrive.DeviceID & @CRLF) MsgBox("", "", "Network path: " & $objDrive.ProviderName & @CRLF) Next Jérôme Edited September 29, 2010 by Jerome60 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