forked from rdotnet/rdotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessFactory.cs
33 lines (30 loc) · 1.04 KB
/
ProcessFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace RDotNet.Client
{
public class ProcessFactory : IProcessFactory
{
public IProcess Create(string path, string args, IDictionary<string, string> environmentVariables )
{
var psi = new ProcessStartInfo(path, args)
{
/* CreateNoWindow = true,
ErrorDialog = false,
WindowStyle = ProcessWindowStyle.Hidden
*/};
psi.UseShellExecute = false;
foreach (var environmentVariable in environmentVariables)
{
Environment.SetEnvironmentVariable( environmentVariable.Key, environmentVariable.Value );
}
var process = Process.Start(psi);
return new ProcessWrapper(process);
}
public List<IProcess> GetProcessesByName(string name)
{
return new List<IProcess>(Process.GetProcessesByName(name).Select(s => new ProcessWrapper(s)));
}
}
}