user34308: I want my C# application to automatically select the correct COM port by way of a string equality check against a 'GetInfo'-type request to the Arduino board.     
I know the Arduino IDE can get info from the board;     
Tools > GetBoardInfo 

But I don't know how to get it using a sketch or if it is even possible for that matter.
Is this something that can be read from the board, or is it a USB-thing. If it's a USB thing, I'd have to get the info from GetUSBDevices.DeviceID or whatever, then get the serial port used by the USB Device, which would probably work, but I'd rather do it all via a serialPort.

user40986: Please look here https://todbot.com/blog/2012/03/02/listcomports-windows-command-line-tool-for-usb-to-serial/
The article is right about what you are seeking.
Thanks to @Johnny Mopp, searching "listComPorts" keyword helped me.
Quote from that article:

How it works
The C and the VBS versions both utilize the WMI
infrastructure that’s been around since Windows 2000 to query the
machine about its configured PnP devices. The WMI is a huge data
structure of just about any information in Windows. Except, it seems,
good information about COM ports. While there is a “Win32_SerialPort”
table in WMI, that only contains information about hardware serial
ports, not USB-to-serial adapters. Instead, these two tools look at
the “Win32_PnPEntity” table. While this table does list USB-to-serial
adapters, it does not contain a proper mapping of the adapter’s USB or
PnP ID to COM port. Instead, these tools do a string search on the
“Caption” field for the string “(COMn)” where “n” is a number. It’s an
incredible hack but seems to work.


user13425: Looking at the source code of the Arduino IDE on github, it looks like they call an executable (listComPorts.exe). So I would guess you can't get that info through serial.
Here's a C# app using WMI that can get port, vid, and pid:
namespace PortTest
{
    class Program
    {
        // Helper function to handle regex search
        static string regex(string pattern, string text)
        {
            Regex re = new Regex(pattern);
            Match m = re.Match(text);
            if (m.Success)
            {
                return m.Value;
            }
            else
            {
                return null;
            }
        }

        static void Main(string[] args)
        {
            // Use WMI to get info
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2",
                "SELECT * FROM Win32_PnPEntity WHERE ClassGuid=\"{4d36e978-e325-11ce-bfc1-08002be10318}\"");

            // Search all serial ports
            foreach (ManagementObject queryObj in searcher.Get())
            {
                // Parse the data
                if (null != queryObj["Name"])
                {
                    Console.WriteLine("Port = " + regex(@"(\(COM\d+\))", queryObj["Name"].ToString()));
                }
                //PNPDeviceID = USB\VID_1A86&PID_7523\5&1A63D808&0&2
                if (null != queryObj["PNPDeviceID"])
                {
                    Console.WriteLine("VID = " + regex("VID_([0-9a-fA-F]+)", queryObj["PNPDeviceID"].ToString()));
                    Console.WriteLine("PID = " + regex("PID_([0-9a-fA-F]+)", queryObj["PNPDeviceID"].ToString()));
                }
            }
            Console.WriteLine("Done");
            int c = Console.Read();
        }
    }
}

From there, it looks like it searches an online database for more info. See: getBoardWithMatchingVidPidFromCloud() function.

34308: <p>I want my C# application to automatically select the correct COM port by way of a string equality check against a 'GetInfo'-type request to the Arduino board.     </p>

<p>I know the Arduino IDE can get info from the board;     </p>

<p><code>Tools &gt; GetBoardInfo</code>     </p>

<p><a href="https://i.stack.imgur.com/mPjNz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mPjNz.png" alt="enter image description here"></a></p>

<p>But I don't know how to get it using a sketch or if it is even possible for that matter.</p>

<p>Is this something that can be read from the board, or is it a USB-thing. If it's a USB thing, I'd have to get the info from <code>GetUSBDevices.DeviceID</code> or whatever, then get the serial port used by the USB Device, which would probably work, but I'd rather do it all via a <code>serialPort</code>.</p>
 40986: <p>Please look here <a href="https://todbot.com/blog/2012/03/02/listcomports-windows-command-line-tool-for-usb-to-serial/" rel="nofollow noreferrer">https://todbot.com/blog/2012/03/02/listcomports-windows-command-line-tool-for-usb-to-serial/</a>
The article is right about what you are seeking.
Thanks to @Johnny Mopp, searching &quot;listComPorts&quot; keyword helped me.</p>
<p>Quote from that article:</p>
<blockquote>
<p><strong>How it works</strong></p>
<p>The C and the VBS versions both utilize the WMI
infrastructure that’s been around since Windows 2000 to query the
machine about its configured PnP devices. The WMI is a huge data
structure of just about any information in Windows. Except, it seems,
good information about COM ports. While there is a “Win32_SerialPort”
table in WMI, that only contains information about hardware serial
ports, not USB-to-serial adapters. Instead, these two tools look at
the “Win32_PnPEntity” table. While this table does list USB-to-serial
adapters, it does not contain a proper mapping of the adapter’s USB or
PnP ID to COM port. Instead, these tools do a string search on the
“Caption” field for the string “(COMn)” where “n” is a number. It’s an
incredible hack but seems to work.</p>
</blockquote>
 13425: <p>Looking at the source code of the Arduino IDE on github, it looks like they call an executable (listComPorts.exe). So I would guess you can't get that info through serial.</p>

<p>Here's a C# app using WMI that can get port, vid, and pid:</p>

<pre><code>namespace PortTest
{
    class Program
    {
        // Helper function to handle regex search
        static string regex(string pattern, string text)
        {
            Regex re = new Regex(pattern);
            Match m = re.Match(text);
            if (m.Success)
            {
                return m.Value;
            }
            else
            {
                return null;
            }
        }

        static void Main(string[] args)
        {
            // Use WMI to get info
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2",
                "SELECT * FROM Win32_PnPEntity WHERE ClassGuid=\"{4d36e978-e325-11ce-bfc1-08002be10318}\"");

            // Search all serial ports
            foreach (ManagementObject queryObj in searcher.Get())
            {
                // Parse the data
                if (null != queryObj["Name"])
                {
                    Console.WriteLine("Port = " + regex(@"(\(COM\d+\))", queryObj["Name"].ToString()));
                }
                //PNPDeviceID = USB\VID_1A86&amp;PID_7523\5&amp;1A63D808&amp;0&amp;2
                if (null != queryObj["PNPDeviceID"])
                {
                    Console.WriteLine("VID = " + regex("VID_([0-9a-fA-F]+)", queryObj["PNPDeviceID"].ToString()));
                    Console.WriteLine("PID = " + regex("PID_([0-9a-fA-F]+)", queryObj["PNPDeviceID"].ToString()));
                }
            }
            Console.WriteLine("Done");
            int c = Console.Read();
        }
    }
}
</code></pre>

<p>From there, it looks like it searches an online database for more info. See: <a href="https://github.com/arduino/Arduino/blob/master/arduino-core/src/processing/app/Platform.java" rel="noreferrer"><code>getBoardWithMatchingVidPidFromCloud()</code></a> function.</p>
