public Process LaunchProcess(ProcessExecutionContextArgs args) { Utility.Code.Require(args, "args"); int pid = this.Framework.LaunchProcessWithDebuggerAttached(args.FilePath, args.WorkingDirectory, args.Arguments, args.EnvironmentVariables); return Process.GetProcessById(pid); }
public Process LaunchProcess(ProcessExecutionContextArgs args) { Utility.Code.Require(args, "args"); int pid = this.Framework.LaunchProcessWithDebuggerAttached(args.FilePath, args.WorkingDirectory, args.Arguments, args.EnvironmentVariables); return(Process.GetProcessById(pid)); }
public Process LaunchProcess(ProcessExecutionContextArgs args) { Process process = Process.Start(CreateStartInfo(args)); if (!this.JobObject.AddProcess(process)) { Logger.Warn("Process could not be added to Job Object. Test process may end up orphaned on abrupt closure."); } return(process); }
public Process LaunchProcess(ProcessExecutionContextArgs args) { Process process = Process.Start(CreateStartInfo(args)); if (!this.JobObject.AddProcess(process)) { Logger.Warn("Process could not be added to Job Object. Test process may end up orphaned on abrupt closure."); } return process; }
/// <summary> /// Creates a ProcessStartInfo instance from the provided ProcessExecutionContextArgs instance /// </summary> /// <param name="args">ProcessExecutionContextArgs</param> /// <returns>A ProcessStartInfo which represents the provided ProcessExecutionContextArgs instance</returns> /// <remarks>The spawned process is executed through a cmd.exe instance to make the behavior similar to IFrameworkHandle.LaunchProcessWithDebuggerAttached</remarks> private static ProcessStartInfo CreateStartInfo(ProcessExecutionContextArgs args) { ProcessStartInfo startInfo = new ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = args.WorkingDirectory, // Start the process through cmd.exe to allow redirection operators to work as expected FileName = "cmd.exe", Arguments = "/S /C \"\"" + args.FilePath + "\" " + args.Arguments + '"', // Redirection should be specified as part of 'args.Arguments' and sent to a file RedirectStandardError = false, RedirectStandardInput = false }; if (args.EnvironmentVariables != null) { foreach (var variable in args.EnvironmentVariables) { // Sets variable accordingly to the environment if (startInfo.EnvironmentVariables.ContainsKey(variable.Key)) { startInfo.EnvironmentVariables[variable.Key] = variable.Value; } else { startInfo.EnvironmentVariables.Add(variable.Key, variable.Value); } } } return(startInfo); }
/// <summary> /// Creates a ProcessStartInfo instance from the provided ProcessExecutionContextArgs instance /// </summary> /// <param name="args">ProcessExecutionContextArgs</param> /// <returns>A ProcessStartInfo which represents the provided ProcessExecutionContextArgs instance</returns> /// <remarks>The spawned process is executed through a cmd.exe instance to make the behavior similar to IFrameworkHandle.LaunchProcessWithDebuggerAttached</remarks> private static ProcessStartInfo CreateStartInfo(ProcessExecutionContextArgs args) { ProcessStartInfo startInfo = new ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = args.WorkingDirectory, // Start the process through cmd.exe to allow redirection operators to work as expected FileName = "cmd.exe", Arguments = "/S /C \"\"" + args.FilePath + "\" " + args.Arguments + '"', // Redirection should be specified as part of 'args.Arguments' and sent to a file RedirectStandardError = false, RedirectStandardInput = false }; if (args.EnvironmentVariables != null) { foreach (var variable in args.EnvironmentVariables) { // Sets variable accordingly to the environment if (startInfo.EnvironmentVariables.ContainsKey(variable.Key)) { startInfo.EnvironmentVariables[variable.Key] = variable.Value; } else { startInfo.EnvironmentVariables.Add(variable.Key, variable.Value); } } } return startInfo; }