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;
35 using System.Security.Permissions;
37 namespace System.Diagnostics
39 [TypeConverter (typeof (ExpandableObjectConverter))]
40 [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
41 public sealed class ProcessStartInfo
44 private string arguments = "";
45 private bool create_no_window = false;
46 private bool error_dialog = false;
47 private IntPtr error_dialog_parent_handle = (IntPtr)0;
48 private string filename = "";
49 private bool redirect_standard_error = false;
50 private bool redirect_standard_input = false;
51 private bool redirect_standard_output = false;
52 private bool use_shell_execute = true;
53 private string verb = "";
54 private ProcessWindowStyle window_style = ProcessWindowStyle.Normal;
55 private string working_directory = "";
56 private ProcessStringDictionary envVars;
58 public ProcessStartInfo()
62 public ProcessStartInfo(string filename)
64 this.filename = filename;
67 public ProcessStartInfo(string filename, string arguments)
69 this.filename = filename;
70 this.arguments = arguments;
73 [RecommendedAsConfigurable (true), DefaultValue ("")]
74 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
76 [MonitoringDescription ("Command line agruments for this process.")]
77 public string Arguments {
86 [DefaultValue (false)]
87 [MonitoringDescription ("Start this process with a new window.")]
88 public bool CreateNoWindow {
90 return(create_no_window);
93 create_no_window = value;
97 [MonoTODO("Need to read the env block somehow")]
98 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content), DefaultValue (null)]
99 [Editor ("System.Diagnostics.Design.StringDictionaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
100 [MonitoringDescription ("Environment variables used for this process.")]
101 public StringDictionary EnvironmentVariables {
103 if (envVars == null) {
104 envVars = new ProcessStringDictionary ();
105 foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables ())
106 envVars.Add ((string) entry.Key, (string) entry.Value);
113 internal bool HaveEnvVars {
114 get { return (envVars != null && envVars.Count > 0); }
117 [DefaultValue (false)]
118 [MonitoringDescription ("Thread shows dialogboxes for errors.")]
119 public bool ErrorDialog {
121 return(error_dialog);
124 error_dialog = value;
128 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
129 public IntPtr ErrorDialogParentHandle {
131 return(error_dialog_parent_handle);
134 error_dialog_parent_handle = value;
138 [RecommendedAsConfigurable (true), DefaultValue ("")]
139 [Editor ("System.Diagnostics.Design.StartFileNameEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
140 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
141 [MonitoringDescription ("The name of the resource to start this process.")]
142 public string FileName {
151 [DefaultValue (false)]
152 [MonitoringDescription ("Errors of this process are redirected.")]
153 public bool RedirectStandardError {
155 return(redirect_standard_error);
158 redirect_standard_error = value;
162 [DefaultValue (false)]
163 [MonitoringDescription ("Standard input of this process is redirected.")]
164 public bool RedirectStandardInput {
166 return(redirect_standard_input);
169 redirect_standard_input = value;
173 [DefaultValue (false)]
174 [MonitoringDescription ("Standart output of this process is redirected.")]
175 public bool RedirectStandardOutput {
177 return(redirect_standard_output);
180 redirect_standard_output = value;
184 [DefaultValue (true)]
185 [MonitoringDescription ("Use the shell to start this process.")]
186 public bool UseShellExecute {
188 return(use_shell_execute);
191 use_shell_execute = value;
196 [TypeConverter ("System.Diagnostics.Design.VerbConverter, " + Consts.AssemblySystem_Design)]
197 [MonitoringDescription ("The verb to apply to a used document.")]
208 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
209 public string[] Verbs {
215 [DefaultValue (typeof (ProcessWindowStyle), "Normal")]
216 [MonitoringDescription ("The window style used to start this process.")]
217 public ProcessWindowStyle WindowStyle {
219 return(window_style);
222 window_style = value;
226 [RecommendedAsConfigurable (true), DefaultValue ("")]
227 [Editor ("System.Diagnostics.Design.WorkingDirectoryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
228 [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
229 [MonitoringDescription ("The initial directory for this process.")]
230 public string WorkingDirectory {
232 return(working_directory);
235 working_directory = value;