I've made an application for this case. Using the batch file with following command, I made a process that executes the .bat file and stores the ip in variable ip
//make a batch file and write this in it
File.WriteAllText(FolderPath + "\\getip.bat", "@echo off \r\n FOR /F \"tokens=1-6 delims=:. \" %%a in ('netsh int ip show address \"SanadConnectVPN\" ^|find \"IP Address\"') do set IP=%%c.%%d.%%e.%%f \r\n echo %IP%");
var newProcess = new Process
{
StartInfo =
{
FileName = FolderPath + "\\getip.bat",
WindowStyle = ProcessWindowStyle.Normal
}
};
newProcess.StartInfo.RedirectStandardOutput = true;
newProcess.StartInfo.UseShellExecute = false;
newProcess.Start();
string ip = newProcess.StandardOutput.ReadToEnd();
newProcess.WaitForExit();
MessageBox.Show(ip);
return ip