Sign in to follow this  
Followers 0
memnon

resolve remote computername

13 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Using ping -a with Run() should do it

Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You can use WMI to get the remote host name.

ping -a will only work when a DNS is available!

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I don't know whether _TCPIpToName will work when there is no DNS/WINS available.

Here a WMI version:

 

;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 by UEZ
1 person likes this

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by minimen456

Share this post


Link to post
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#11 ·  Posted (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

post-77820-0-21956900-1360928322_thumb.j

Edited by minimen456

Share this post


Link to post
Share on other sites

#12 ·  Posted (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 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Now it works. Thanks

Share this post


Link to post
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
Sign in to follow this  
Followers 0