I am working on ASP.NET 4.0 and Visual Studio 2010.In my Web Project I am running a Command Process to get Physical Address of the System and Coping the result and assigning it to string variable and doing substring of the String variable to get the desired result only.In my localhost it is working correcltly,but when I deploy it I get the System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. exception.The Code I tried is,
string command = "getmac";
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo("cmd", "/c " + command);
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
process.StartInfo = startInfo;
process.Start();
string mac = "";
string output = process.StandardOutput.ReadToEnd();
if (!string.IsNullOrEmpty(output))
{
mac = output.Substring(162, 20).Trim();
}
process.WaitForExit();
if (!string.IsNullOrEmpty(mac))
{
mactxtbox.Text = mac;
}
Edit
The below is my output Variable
Physical Address Transport Name
=================== ==========================================================
00-00-00-00-00-00 \Device\Tcpip_{00000000-0000-0000-0000-000000000000}
all I want is Just that Physical Address in the format 00-00-00-00-00-00