Jump to content

Recommended Posts

Posted

Hi all,

I need to determine the hostname for the system post ghost install. The goal is to rename the computer description and hostname based on the steps below:

1. Run ipconfig (IP address served via DHCP MAC address reservation)

2. Copy the IP address

3. Search for the IP address in a text file located directly under C:

4. Once I find the IP address in the text file, then copy the hostname. The line contains this: 0.0.0.0 abc.group.com

The list is going to have multiple IP addresses with hostsnames, and each machine will need to repeat the same step post ghost. Would this be the correct approach?

Suggestions?

Posted (edited)

You can use the macros @IPAddress1 and @ComputerName. There is also @IPAddress2,@IPAddress3,and @IPAddress4.

For Example:

MsgBox(0,"Test","Your computer name is: "& @ComputerName&@CRLF&"Your IP1 is: "&@IPAddress1)
Edited by P5ych0Gigabyte
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Posted

FileOpen, FileReadLine in a loop, FileClose. Something like that. You could also use FileRead and split each line instead of filereadline. This would be a bit faster, but slightly more difficult.

Posted

What I have so far:

$file = FileOpen("C:\list.txt", 0)
$IPAddress = String(@IPAddress1)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    Select
        Case @error = -1
            MsgBox (0, "Search Result", "End Of File was met")
            ExitLoop
        Case StringInStr($line, @IPAddress1)
            MsgBox (0, "Search Result", $line)
            ExitLoop
    EndSelect
WEnd

FileClose($file)

See anything I can improve on?

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...