memnon Posted February 9, 2011 Share Posted February 9, 2011 hello is there an autoit function to get the name of a remote pc (like ping -a x.x.x.x from dos ?) thx for answer das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum? Link to comment Share on other sites More sharing options...
Steveiwonder Posted February 9, 2011 Share Posted February 9, 2011 (edited) Using ping -a with Run() should do it Edited February 9, 2011 by Steveiwonder They call me MrRegExpMan Link to comment Share on other sites More sharing options...
UEZ Posted February 9, 2011 Share Posted February 9, 2011 (edited) You can use WMI to get the remote host name. ping -a will only work when a DNS is available! Br, UEZ Edited February 9, 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...
memnon Posted February 9, 2011 Author Share Posted February 9, 2011 thx... found a wy with autoit functions... _TCPIpToName das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum? Link to comment Share on other sites More sharing options...
UEZ Posted February 9, 2011 Share Posted February 9, 2011 (edited) I don't know whether _TCPIpToName will work when there is no DNS/WINS available. Here a WMI version: expandcollapse popup;code by UEZ 2011 Global Const $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler") $sIP = "127.0.0.1" MsgBox(0, "Get Host Name", "IP: " & $sIP & " -> Host Name: " & WMI_GetHostName($sIP)) Func WMI_GetHostName($host) Local $HostNameWMI, $colItems, $colItem, $ping $ping = Ping($host) If $ping Then $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $host & "\root\cimv2") If @error Then Return SetError(2, 0, "") $colItems = $objWMIService.ExecQuery("SELECT SystemName FROM Win32_NetworkAdapter WHERE NetConnectionStatus=2", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems If $objItem.SystemName = "" Then Return SetError(3, 0, "") Return $objItem.SystemName Next Return $HostNameWMI Else Return SetError(3, 0, "") EndIf Else Return SetError(1, 0, "") EndIf EndFunc Func ObjErrorHandler() ConsoleWrite( "A COM Error has occured!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB & $oErrorHandler & @CRLF & _ "err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _ "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext & @CRLF _ ) EndFunc Br, UEZ Edited May 14, 2013 by UEZ minimen456 1 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...
memnon Posted February 9, 2011 Author Share Posted February 9, 2011 thx again, i will keep it alternative das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum? Link to comment Share on other sites More sharing options...
minimen456 Posted February 15, 2013 Share Posted February 15, 2013 2UEZ: script is not working. I'm getting error message: ==> Variable must be of type "Object".: $colItems = $objWMIService.ExecQuery("SELECT DNSHostName FROM Win32_ComputerSystem", "WQL", 0x30) $colItems = $objWMIService^ ERROR What's wrong? Link to comment Share on other sites More sharing options...
UEZ Posted February 15, 2013 Share Posted February 15, 2013 (edited) 2UEZ: script is not working. I'm getting error message: ==> Variable must be of type "Object".: $colItems = $objWMIService.ExecQuery("SELECT DNSHostName FROM Win32_ComputerSystem", "WQL", 0x30) $colItems = $objWMIService^ ERROR What's wrong? I added an error handling to the code. Post the result from the console. Did you run it with "127.0.0.1" or with a different host? Br, UEZ Edited February 15, 2013 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...
minimen456 Posted February 15, 2013 Share Posted February 15, 2013 (edited) Thanks for quick respond. I ran it with 127.0.0.1. I've got error message: A COM Error has occured! err.description is: err.windescription: err.number is: 80041017 err.lastdllerror is: 0 err.scriptline is: 11 err.source is: err.helpfile is: err.helpcontext is: 7602293 Then I added #RequireAdmin to the script. There was no error message this time but I didn't get any MsgBox (with computer name) Edited February 15, 2013 by minimen456 Link to comment Share on other sites More sharing options...
UEZ Posted February 15, 2013 Share Posted February 15, 2013 Disable UAC and try again or compile and run it. Br, 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...
minimen456 Posted February 15, 2013 Share Posted February 15, 2013 (edited) I did what you've said. There isn't any information in the MsgBox. I tried both to run exe-file as User and RunAs Admin Edited February 15, 2013 by minimen456 Link to comment Share on other sites More sharing options...
UEZ Posted February 15, 2013 Share Posted February 15, 2013 (edited) You are using WinXP and DNSHostName method is not availabe for XP. I changed the code above again. Please try again. Br, UEZ Edited February 15, 2013 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...
minimen456 Posted February 15, 2013 Share Posted February 15, 2013 Now it works. Thanks 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