Jump to content

ComputerName over GUID


kobo3

Recommended Posts

Hello,

I searched the complete Internet without success ... :-( ....

I'am looking for a way to get the computer name (with my HTA Sycript) from the Active Directory. The GUID (Computers Unique ID) is maintained for each computer in the Active Directory.

Or is there any other way to get the Computername with a script from the Registry File of the old System (C:\WINDOWS\System32\Config\System)?

I'am trying to make a full automated Sysprep Installation of Windows XP ....

Thanks,

Kobo3

Link to comment
Share on other sites


Hello,

I searched the complete Internet without success ... :-( ....

I'am looking for a way to get the computer name (with my HTA Sycript) from the Active Directory. The GUID (Computers Unique ID) is maintained for each computer in the Active Directory.

Or is there any other way to get the Computername with a script from the Registry File of the old System (C:\WINDOWS\System32\Config\System)?

I'am trying to make a full automated Sysprep Installation of Windows XP ....

Thanks,

Kobo3

It's going to be a pain in the a** to get the computer name from the registry, because you'd have to mount the hives sitting in system32\config and then be able to edit them automatically somehow. It'd be a lot easier to create a GPO that runs on every computer that simply calls this batch file:

@echo off

echo %computername% > c:\windows\computername.txt

That way, in your startnet.cmd you can do something like...

set /p oldpcname=>c:\windows\computername.txt

So, you hang onto that variable and image the machine... Then once it's imaged, you inject that into your sysprep.inf.

I haven't found a good find and replace tool that works in WinPE 2.1 yet...so you could copy the sysprep.inf to the PE image, sans the ComputerName= portion, have another text file called sysprep1.txt that had this:

[userData]

ComputerName =

Then you could echo %oldpcname% > whatever.txt and mash them together with copy /b whatever.txt + sysprep1.txt + sysprep.inf c:\sysprep\sysprep.inf

It's a Charlie Foxtrot way to go about it, but it got the job done for me...

Link to comment
Share on other sites

I haven't found a good find and replace tool that works in WinPE 2.1 yet...

FYI:

The AutoIt3 scripting language is easy to use and has great built in functions to do search and replace. I use it exactly for what you are describing here. The scripts can be compiled into native x86 or x64 EXE files, so they will work in any WinPE environment.

EDIT:

I put this Autoit script togeather to show you how you can load the hive, grab the computername, and edit your sysprep.inf file with the wanted computername. Of course there would be a number of steps between these, just showing you how it can be done.

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Program Files\AutoIt3\Icons\filetype2.ico
#AutoIt3Wrapper_outfile=.\GrabComputerName.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Grab Computer Name
#AutoIt3Wrapper_Res_Description=Grab Computer Name
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=© 2008
#AutoIt3Wrapper_Res_Language=1033
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.10.0
Author: Jazkal
Date: 05/06/2008
Script Function: Grab Computer Name
#ce ----------------------------------------------------------------------------

RunWait(@ComSpec&" /c reg load HKLM\PE-SYS C:\Windows\system32\config\system", "", @SW_HIDE)
Sleep(500)

$thisComputersName = RegRead("HKLM\PE-SYS\ControlSet001\Control\ComputerName\ComputerName", "ComputerName")

RunWait(@ComSpec&" /c reg unload HKLM\PE-SYS", "", @SW_HIDE)

IniWrite("C:\Sysprep\sysprep.inf", "UserData", "ComputerName", $thisComputersName)

Edited by Jazkal
Link to comment
Share on other sites

Hey,

cool Great

that seems to be something what I'am looking for... So I will compile a .exe which is creating me textfile with the computername ...

I already created a hta file with a GUI for the other deploying stuff .....

But if there is anybody who knows a way to query the Computername with the UUID from the AD, I'am also interested in.... :-)

Thanks for all your Help!

kobo3

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...