Jump to content

Recommended Posts

Posted

Hey!

I made a small script that tells me which PCs in my factory's network are online.

Now i need to get the Computer name to a specific ip!

I know that it works with CMD:

nslookup %IP%

But i need / want a similar function for autoit..

I know i could use this cmd command in autoit but i just want to get the PC name and nslookup gives some more things back...

Anybody knows such a function?

Posted (edited)

No the other way! :graduated:

#include <iNet.au3>

(EDIT) TCPStartup ( )

$test = _TCPIpToName ( "192.168.40.56" )

ConsoleWrite( $test )

Returns nothing

*facepalm

Edited by jWalker
Posted (edited)

Try this:

#include <Constants.au3>
Global $ip = @IPAddress1
MsgBox(0, "Test", IP2HOST($ip))

Func IP2HOST($ip) ;coded by UEZ 2011
    Local $run = Run(@ComSpec & " /c ping -a -n 1 -4 " & $ip, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
    Local $line
    While 1
        $line &= StdoutRead($run)
        If @error Then ExitLoop
    Wend
    Local $aResult = StringRegExp($line, "(?Um).*\h(.*)\h\[.*", 3)
    If @error Then Return SetError(1, 0, 0)
    Return $aResult[0]
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Thanks for That UEZ But

#include <iNet.au3>

(EDIT) TCPStartup ( )

$test = _TCPIpToName ( "192.168.40.56" )

ConsoleWrite( $test )

This works too.. i simply forgot TCPStartup()

Posted

Thanks UEZ adding to my function folder :graduated:

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted (edited)

ping -a -n 1 -4 " & $ip

That only seems to work for the local machine for me (using XP Pro SP3).

On remote machines, "ping -a" just outputs "Pinging 192.168.0.5 ...", with no name resolution.

I can ping those same machines using their hostname, instead of IP, with no problem.

What is the -4 parm?

The other _TCPIpToName() method seems to work, but if you scan a range with it, it takes forever to return.

Non-existant IP's aren't handled very quickly. I cancelled a half-complete 0 to 255 scan after 10 minutes.

Edit: the -w option can get Ping chewing through the bad IP's quickly, but, as I said, Ping -a only returns names for the local machine or websites. DHCP is turned off on our switch and we're all using static IP's, but I can still ping successfully using the hostnames.

Edited by Spiff59
Posted (edited)

That only seems to work for the local machine for me (using XP Pro SP3).

On remote machines, &quot;ping -a&quot; just outputs &quot;Pinging 192.168.0.5 ...&quot;, with no name resolution.

I can ping those same machines using their hostname, instead of IP, with no problem.

What is the -4 parm?

The other _TCPIpToName() method seems to work, but if you scan a range with it, it takes forever to return.

Scanning 0 to 255 took almost 10 minutes!

Hi Spiff59,

this is just an alternative to the build-in TCPNameToIP() function. Of course any name resolution (DNS, WINS,Hosts, Computer Browser) must work to resolve the ip address to host name.

My test system is Win7 X64 (joined to a DNS integrated AD domain) and thus some options in the ping.exe app might be different.

Here the ping options on my system

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
            [-r count] [-s count] [[-j host-list] | [-k host-list]]
            [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name

Options:
    -t             Ping the specified host until stopped.
                   To see statistics and continue - type Control-Break;
                   To stop - type Control-C.
    -a             Resolve addresses to hostnames.
    -n count       Number of echo requests to send.
    -l size        Send buffer size.
    -f             Set Don't Fragment flag in packet (IPv4-only).
    -i TTL         Time To Live.
    -v TOS         Type Of Service (IPv4-only. This setting has been deprecated
                   and has no effect on the type of service field in the IP Header).
    -r count       Record route for count hops (IPv4-only).
    -s count       Timestamp for count hops (IPv4-only).
    -j host-list   Loose source route along host-list (IPv4-only).
    -k host-list   Strict source route along host-list (IPv4-only).
    -w timeout     Timeout in milliseconds to wait for each reply.
    -R             Use routing header to test reverse route also (IPv6-only).
    -S srcaddr     Source address to use.
    -4             Force using IPv4.
    -6             Force using IPv6.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

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