Sign in to follow this  
Followers 0
willywill

determine hostname script

5 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  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.

Share this post


Link to post
Share on other sites

That macros help. I think the only remaining part is to search for the IP address in the list and match it to the hostname. any help there?

Share this post


Link to post
Share on other sites

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.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

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?

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