How to receive data from PC without open Tera Term?

I need location data from PC and use them do something else. Based on the official documents, I should install Tera Term and open it first, then I select right COM port and right baud rate just based on the official documents. And then enter twice and input “lep”, the Tera Term will receive the location of the tags. I want to make one program to simulate the Tera Term by C# language. My codes are below:

var mySerialPort = new SerialPort(ComPortName);
mySerialPort.BaudRate = 115200;
mySerialPort.Parity = Parity.None;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits =8;
mySerialPort.Handshake = Handshake.None;
mySerialPort.Open();
And I input some code to simulate the operation of enter twice and “lep” command. But it can’t work. I still need open Tera Term and do some next operation. I can’t figure it until now. Some one can help me? My input command are below:
mySerialPort.Write("\r");
mySerialPort.Write("\r");
mySerialPort.Write(“lep\r”);

3Q

You have to specify what to do whith the data received.

mySerialPort.DataReceived += new SerialDataReceivedEventHandler(OnSocketDataReceived);


private void OnSocketDataReceived(object sender, SerialDataReceivedEventArgs e)
{
//Manage data received
}

Yes I do read the data like this
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (serialPort1.IsOpen)
{

                string inData = serialPort1.ReadExisting();
         }

}

But as I mentioned the DataReceived is not triggering for the first time and if we open the Tera command program and then open my applicatoin the DataReceived event is tiriggering and we get the result.