I am having trouble trying to get this to work.

What I am trying to achieve: use CMD to run a net view command and put the results into a XML file that looks something like this.

<Net_View>
    <result id=1>
        Andy's Computers.
    </result>
    <result id=2>
        Chris PC
    </result>
</Net_View>

Sorry for not posting more code!!

protected static void Main(string[] args)
    {
        string output = string.Empty;
        string error = string.Empty;

        using (Process cmd = new Process())
        {
            cmd.StartInfo.FileName = "cmd.exe";
            cmd.StartInfo.Arguments = "/c Net View /all";

            cmd.StartInfo.CreateNoWindow = true;
            cmd.StartInfo.UseShellExecute = false;
            cmd.StartInfo.RedirectStandardOutput = true;

            cmd.Start();

            while (!cmd.StandardOutput.EndOfStream)
            {
                string line = cmd.StandardOutput.ReadLine();

                if (line == "There are no entries in the list.")
                  return null;

                if (line != string.Empty)
                {
                    if (line[0] == "\\")
                }

            }

            using (StreamReader str = cmd.StandardOutput)
            {

            }

            using (StreamReader str = cmd.StandardOutput)
            {
                error = str.ReadToEnd();
            }


                string SANG = cmd.StandardOutput.ReadToEnd();


            cmd.Close();

        }
    }

Related posts

Recent Viewed