You can use this code:
void Login(string pathtofile)
{
Process process = new Process();
process.StartInfo.FileName = pathtofile;
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(process_Exited);
process.Start();
}
void process_Exited(object sender, EventArgs e)
{
Process p = (Process)sender;
int exitCode = p.ExitCode;
}
But note that the Login function will directly exit after starting the process so you cannot return an integer value. You get the exit code in the function process_exited