Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find Computer Name via Windows Registry ?

Status
Not open for further replies.

sergeiY

Programmer
Feb 13, 2003
132
AU

Hi

I need to install an app on a number of generic windows boxes all running either NT4.0 Server or Win2000 Server.

What I need to do is to find a computer name of a box. I spend some time going through the registry and I found the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName

although I also found ControlSet001 and ControlSet002 ... so my question is would I found HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName key on a generic NT 4.0 and Win 2000 Server boxes ???

It would've been nice to know that it's always there ... and it would've been nice if this key would exists on other Win OS such as 2000 Professional and XP Server and Professional. Any insights ???

Thank you
 
What's wrong with reading the COMPUTERNAME environment variable?
Works on WinNT4, 2000 and XP. Unfortunately not on 95/98 but you can't have everything.

John
 
The answer you require is - Yes !

This key should be common across both platforms. Always use CurrentControlSet as the ControlSet001/2 refer to previous configuration sets -although it's unlikely the computer name will change between these sets, always use the CurrentControlSet.

Ever wondered how the "...use last known good profile.." gets its info? From CurrentControlSet001/002.....




RosieBsDad
 
ohh OK so now it makes sence so ControlSet00X refers to previous configuration .... OK.

... how do u change a computer configuration ? is it some auto process like windows updates or what ?

Thank you

Sergei
 
Windows will automatically create the previous configurations - don't mess around with them or you will cause yourself more trouble than it's worth.

Personally, I don't trust them anyway. If I ever get to the state where I can only boot by recovering from "last known good profile" it's normally time for a rebuild anyway.

If it's any consolation, I have to rebuild my laptop about every three months - this isn't a dig against W2K, it's just my working environment. (Better than W98 or NT4 which was monthly!)

I use a combination of GHOST and a roaming profile (on my local disk) to recover to a good working system, takes about two hours now in total. GHOST image has OS and key applications, just add the extras as required. Image file is about 1.3Gb, stored on FAT32 partition. Boot from floppy, run GHOST, get a coffee and and a rebuilt laptop!



RosieBsDad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top