2 // System.Diagnostics.ProcessStartInfo.cs
5 // Dick Porter (dick@ximian.com)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) 2002 Ximian, Inc. http://www.ximian.com
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
33 using System.Collections.Specialized;
34 using System.ComponentModel;
36 namespace System.Diagnostics
38 [TypeConverter (typeof (ExpandableObjectConverter))]
39 public sealed class ProcessStartInfo
42 private string arguments = "";
43 private bool create_no_window = false;
44 private bool error_dialog = false;
45 private IntPtr error_dialog_parent_handle = (IntPtr)0;
46 private string filename = "";
47 private bool redirect_standard_error = false;
48 private bool redirect_standard_input = false;
49 private bool redirect_standard_output = false;
50 private bool use_shell_execute = true;
51 private string verb = "";
52 private ProcessWindowStyle window_style = ProcessWindowStyle.Normal;
53 private string working_directory = "";
54 private ProcessStringDictionary envVars;
56 public ProcessStartInfo()
60 public ProcessStartInfo(string filename)
62 this.filename = filename;
65 public ProcessStartInfo(string filename, string arguments)
67 this.filename = filename;
68 this.arguments = arguments;
71 [RecommendedAsConfigurable (true), DefaultValue ("")]
72 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
74 [MonitoringDescription ("Command line agruments for this process.")]
75 public string Arguments {
84 [DefaultValue (false)]
85 [MonitoringDescription ("Start this process with a new window.")]
86 public bool CreateNoWindow {
88 return(create_no_window);
91 create_no_window = value;
95 [MonoTODO("Need to read the env block somehow")]
96 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content), DefaultValue (null)]
97 [Editor ("System.Diagnostics.Design.StringDictionaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
98 [MonitoringDescription ("Environment variables used for this process.")]
99 public StringDictionary EnvironmentVariables {
101 if (envVars == null) {
102 envVars = new ProcessStringDictionary ();
103 foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables ())
104 envVars.Add ((string) entry.Key, (string) entry.Value);
111 internal bool HaveEnvVars {
112 get { return (envVars != null && envVars.Count > 0); }
115 [DefaultValue (false)]
116 [MonitoringDescription ("Thread shows dialogboxes for errors.")]
117 public bool ErrorDialog {
119 return(error_dialog);
122 error_dialog = value;
126 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
127 public IntPtr ErrorDialogParentHandle {
129 return(error_dialog_parent_handle);
132 error_dialog_parent_handle = value;
136 [RecommendedAsConfigurable (true), DefaultValue ("")]
137 [Editor ("System.Diagnostics.Design.StartFileNameEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
138 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
139 [MonitoringDescription ("The name of the resource to start this process.")]
140 public string FileName {
149 [DefaultValue (false)]
150 [MonitoringDescription ("Errors of this process are redirected.")]
151 public bool RedirectStandardError {
153 return(redirect_standard_error);
156 redirect_standard_error = value;
160 [DefaultValue (false)]
161 [MonitoringDescription ("Standard input of this process is redirected.")]
162 public bool RedirectStandardInput {
164 return(redirect_standard_input);
167 redirect_standard_input = value;
171 [DefaultValue (false)]
172 [MonitoringDescription ("Standart output of this process is redirected.")]
173 public bool RedirectStandardOutput {
175 return(redirect_standard_output);
178 redirect_standard_output = value;
182 [DefaultValue (true)]
183 [MonitoringDescription ("Use the shell to start this process.")]
184 public bool UseShellExecute {
186 return(use_shell_execute);
189 use_shell_execute = value;
194 [TypeConverter ("System.Diagnostics.Design.VerbConverter, " + Consts.AssemblySystem_Design)]
195 [MonitoringDescription ("The verb to apply to a used document.")]
206 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
207 public string[] Verbs {
213 [DefaultValue (typeof (ProcessWindowStyle), "Normal")]
214 [MonitoringDescription ("The window style used to start this process.")]
215 public ProcessWindowStyle WindowStyle {
217 return(window_style);
220 window_style = value;
224 [RecommendedAsConfigurable (true), DefaultValue ("")]
225 [Editor ("System.Diagnostics.Design.WorkingDirectoryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
226 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
227 [MonitoringDescription ("The initial directory for this process.")]
228 public string WorkingDirectory {
230 return(working_directory);
233 working_directory = value;