jWalker Posted October 19, 2011 Share Posted October 19, 2011 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? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 19, 2011 Share Posted October 19, 2011 TCPNameToIP() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jWalker Posted October 19, 2011 Author Share Posted October 19, 2011 (edited) No the other way! #include <iNet.au3> (EDIT) TCPStartup ( ) $test = _TCPIpToName ( "192.168.40.56" )ConsoleWrite( $test ) Returns nothing *facepalm Edited October 19, 2011 by jWalker Link to comment Share on other sites More sharing options...
UEZ Posted October 19, 2011 Share Posted October 19, 2011 (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 October 19, 2011 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
jWalker Posted October 19, 2011 Author Share Posted October 19, 2011 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() Link to comment Share on other sites More sharing options...
guinness Posted October 19, 2011 Share Posted October 19, 2011 Thanks UEZ adding to my function folder 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Spiff59 Posted October 19, 2011 Share Posted October 19, 2011 (edited) ping -a -n 1 -4 " & $ipThat 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 October 19, 2011 by Spiff59 Link to comment Share on other sites More sharing options...
UEZ Posted October 19, 2011 Share Posted October 19, 2011 (edited) 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. 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 October 19, 2011 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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