static public StringDictionary EnvVars(string ProcName, string Dirname) { RunProcess rp = new RunProcess(ProcName, Dirname); List <DictionaryEntry> de = new List <DictionaryEntry>(); de.Clear(); rp.StartInfo = new ProcessStartInfo(); rp.StartInfo.FileName = ProcName; if (Directory.Exists(Path.GetDirectoryName(Dirname))) { rp.StartInfo.WorkingDirectory = Path.GetDirectoryName(Dirname); } else { throw new ArgumentException("process error: directory name is invalid."); } rp.StartInfo.CreateNoWindow = defaultcreatenowindow; // false rp.StartInfo.UseShellExecute = defaultuseshell; // true? rp.StartInfo.RedirectStandardInput = defaultreadin; //false; rp.StartInfo.RedirectStandardOutput = defaultreadout; // does it matter? StringDictionary sd = new StringDictionary(); foreach (DictionaryEntry kvp in rp.StartInfo.EnvironmentVariables) { sd.Add((string)kvp.Key, (string)kvp.Value); } rp.Dispose(); rp = null; return(sd); }
public static RunProcess QuickCommand(string command) { RunProcess rp = new RunProcess(command, Path.GetFullPath(@"c:\windows\")); return(rp); }
public ProcessEventArgs(RunProcess rp, string data) { RP = rp; Data = data; }