Jump to content
Sign in to follow this  
Markir

Computer Informations

Recommended Posts

Hello,

there is a super macro "@IPAddress1". Give it macros for "subnet mask", gateway, "dns1" & "dns2", too? Thank you for helping me!

Share this post


Link to post
Share on other sites

You can redirect CMD output to a text file.

And parse it with AutoIt.

Functions you need:

RunWait(@ComSpec & " /c ipconfig /all > SomeFile.log")

FileOpen("SomeFile.log", 0)

StringSplit()

StringTrimLeft

StringTrmRight

Share this post


Link to post
Share on other sites

RunWait(@ComSpec & " /c ipconfig /all > c:\compinfo.log")
$file = FileOpen("c:\compinfo.log", 0)
$line = FileReadLine($file)
While Not StringInStr($line, 'Hostname')
    $line = FileReadLine($file)
WEnd
$hn = StringTrimLeft($line, StringInStr($line, ': ')+1)
MsgBox(0, '', $hn)

Share this post


Link to post
Share on other sites

If you need several things, try this code. Alter content of $search_for to those things you need, separated by commas.

$search_for = 'Hostname,DNS-Server,Gateway'

$array = StringSplit($search_for, ',')
Dim $result[$array[0]+1]
RunWait(@ComSpec & " /c ipconfig /all > c:\compinfo.log")
$file = FileOpen("c:\compinfo.log", 0)
$line = FileReadLine($file)
While @error=0
    For $i = 1 To $array[0]
        If StringInStr($line, $array[$i]) Then
            $result[$i] = StringTrimLeft($line, StringInStr($line, ': ')+1)
        EndIf
        $line = FileReadLine($file)
    Next
WEnd
FileClose($file)

For $i = 1 To $array[0]
    MsgBox(0, '', $array[$i] & ': ' & $result[$i])
Next
Edited by ZeDMIN

Share this post


Link to post
Share on other sites

Oh thank you that is a good idea, because I need more informations, but in that code I see the Value "Hostname:PC01", and the word Hostname don't be displayed

Share this post


Link to post
Share on other sites

For $i = 1 To $array[0]

    MsgBox(0, '', $array[$i] & ': ' & $result[$i])

Next

<{POST_SNAPBACK}>

In the MsgBox: The array[$i] is the name of the thing you were looking for. If you only want the result you only have to take result[$i].

Was that what you were asking for?

Share this post


Link to post
Share on other sites

Yes, that was I am asking for. Thank you for coding.

But then the results of the second, third information will be displayed as "0"

Edited by Markir

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...