How can I get remote Machine Name where Console Application resides when it executes?
Posted on 2012-03-26
I am working on an intranet and have 3 different machines: Development, Test, Production. My Development machine is my laptop; the Test machine is a remote server; the Production machine is a different remote server. I built a simple Console Application using C#, and I would like for it to show me the Machine's name (or domain name) where the executable is actually residing when it is run. It may be running from my laptop machine, but I want it to show me the name of the machine where it resides.
Currently I have tried both of the following, but they both give me my laptop's machine name:
using System.Net; //For Dns
string machineName = Environment.MachineName.ToString();
string strHostName = Dns.GetHostName();
What can I do or use to get the machine name (or host name) of the machine where the Console Application resides when it executes?