using (var process = new Process
{
StartInfo = new ProcessStartInfo
{
Verb = "runas",
FileName = "powershell",
UseShellExecute = false,
WorkingDirectory = @"C:\Users\T2\source\repos\Algorithmic-Trading-Server",
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
}
})
{
process.ErrorDataReceived += (sender, e) =>
{
Debug.WriteLine(e.Data);
};
process.OutputDataReceived += (sender, e) =>
{
Debug.WriteLine(e.Data);
};
if (process.Start())
{
process.StandardInput.WriteLine("PowerShell.exe -ExecutionPolicy Bypass -File port.ps1");
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.StandardInput.Close();
process.WaitForExit();
}
}