public string Start <T>(string username) where T : IProcessWrapper { var x = typeof(T); Process = Activator.CreateInstance <T>(); Process.StartInfo = new ProcessStartInfo() { WorkingDirectory = Properties.Settings.Default.SeleniumPath, Arguments = CurrentArgs, FileName = CurrentFileName, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }; Process.EnableRaisingEvents = true; if (username != null) { var cm = CredentialStore.GetCredential(username); Process.StartInfo.Domain = cm.Username.Split('\\')[0]; Process.StartInfo.UserName = cm.Username.Split('\\')[1]; var pass = cm.Password; Console.WriteLine(pass); Process.StartInfo.Password = cm.SecurePassword; } Process.Start(); Process.BeginOutputReadLine(); Process.BeginErrorReadLine(); var proc = new Process(); return(Process.GetProcessUser()); }