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 derfloh 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
Joined
Feb 13, 2003
Messages
132
Location
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
 
sergeiY,

The key exists in the Registry of my 98 machine as well as my 2000 Professional machine...

Not really sure what you are trying to do, but there are much easier ways to determine the name of a computer.

Maybe I'm confused...


Patty [ponytails2]

 
I am installing a remote app on multiple web farms (varios Win OS) and when talking to these remote apps they need to identify themselvs & I choosed to used computerName as I think it's the best candidate.

What else would you suggest ? What other easier ways to determine the name of computer ?
 
Why not just use the environment variable COMPUTERNAME?
echo %computername% will give you the name.

Marc
If 'something' 'somewhere' gives 'some' error, expect random guesses or no replies at all. Please specify details.
Free Tip: The F1 Key does NOT destroy your PC!
 
OK ... my app is written in ASP so I am not sure if I can execute bat commands and not sure if I will be able to grab output ... plus registry sits in server memomry so it must be very quick operation to check registry then enviroment variable.

Thank you for this info I'll play around with it to see if I can use it. Actually it would be intresting to find where this enviroment var is stored is it in some sort of config file or ... is it coming from registry ! :)

Thank you
 
I gave the bat command as example only.
In ASP there is no problem getting an environment variable into the app.
Registry sits in memory? So does the variable! And you will get it faster then any registry entry.
Variables are not in the Registry by definition.
 
Ok this is sounds good. Do you know how can I access enviroment variable in ASP (not ASP.NET) ?

Thank you
 
I can't give the exact code, I don't use it, but a quick look in the help files shoulde reveal that.
And then there is always the ASP forum here.
 
Thank you

I checked I can get Server_Name out of ASP but it gives me server IP address instead of actual computer name

I might redirect it to ASP forum.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top