locked
Getting the name of the server - 2 RRS feed

  • Question

  • Hi guys,

     

    I need to know the name of the server via the console.

    I searched the classes but found nothing, then I searched the forums and saw this post: http://forums.microsoft.com/WindowsHomeServer/ShowPost.aspx?PostID=1670356&SiteID=50

     

    That is the solution for finding the name, but my problem now is that when I read the registry from within the WHS console it returns {self} as name???

     

    This is my code:

    const string key = @"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Home Server\Transport\Server";

    string server = (string)Registry.GetValue(keyName, "Name", "SERVER");

     

    Any idea why this doesn't return the string? Even not the default value...
    I tried this on my local machine by creating the keys on my dev machine and there it works...

     

    Thanks,

    Nick

    Thursday, July 19, 2007 11:11 AM

Answers

  • Did you check with a registry viewing tool? The contents of that key on WHS are {self}. The key with the server name is LateThisMachineName.
    Thursday, July 19, 2007 12:11 PM
    Moderator

All replies

  • Did you check with a registry viewing tool? The contents of that key on WHS are {self}. The key with the server name is LateThisMachineName.
    Thursday, July 19, 2007 12:11 PM
    Moderator
  • Hi Ken,

     

    That was indeed the problem, I seem to have mistaken, between the registry of the client machine (where the connector is on) and the server... I didn't do my research well enough. :-(

     

    Thanks for the quick response!

    Nick

    Thursday, July 19, 2007 12:23 PM
  • If you want the server name you can just query the environment for "COMPUTERNAME".

     

    (Remember, the console is really running on the WHS with the output set to the local machine via terminalservices).

    Thursday, July 19, 2007 6:54 PM
  • Have you tried using Environment.MachineName?
    Saturday, July 21, 2007 5:28 AM
    Moderator