Jump to content

Including Computer name


JeromeB
 Share

Recommended Posts

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.

#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 by Jerome60
Link to comment
Share on other sites

Yes it works on local network ! Posted Image

#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)")
EndIf

it give me my computername !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

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 ;)

Just by the IP, sorry, I don't think so !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

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 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

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

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

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

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.

NiVZ

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

Thx for your reply.

I found the function DriveGetDrive, but can i get the information from a computer in my network ?

Jérôme

Not 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

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 by Jerome60
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...