ProcessStartInfo.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. //
  2. // System.Diagnostics.ProcessStartInfo.cs
  3. //
  4. // Authors:
  5. // Dick Porter ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc. http://www.ximian.com
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System.Collections;
  31. using System.Collections.Specialized;
  32. using System.ComponentModel;
  33. namespace System.Diagnostics
  34. {
  35. [TypeConverter (typeof (ExpandableObjectConverter))]
  36. public sealed class ProcessStartInfo
  37. {
  38. private string arguments = "";
  39. private bool create_no_window = false;
  40. private bool error_dialog = false;
  41. private IntPtr error_dialog_parent_handle = (IntPtr)0;
  42. private string filename = "";
  43. private bool redirect_standard_error = false;
  44. private bool redirect_standard_input = false;
  45. private bool redirect_standard_output = false;
  46. private bool use_shell_execute = true;
  47. private string verb = "";
  48. private ProcessWindowStyle window_style = ProcessWindowStyle.Normal;
  49. private string working_directory = "";
  50. private ProcessStringDictionary envVars;
  51. public ProcessStartInfo()
  52. {
  53. }
  54. public ProcessStartInfo(string filename)
  55. {
  56. this.filename = filename;
  57. }
  58. public ProcessStartInfo(string filename, string arguments)
  59. {
  60. this.filename = filename;
  61. this.arguments = arguments;
  62. }
  63. [RecommendedAsConfigurable (true), DefaultValue ("")]
  64. [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
  65. [MonitoringDescription ("Command line agruments for this process.")]
  66. public string Arguments {
  67. get {
  68. return(arguments);
  69. }
  70. set {
  71. arguments = value;
  72. }
  73. }
  74. [DefaultValue (false)]
  75. [MonitoringDescription ("Start this process with a new window.")]
  76. public bool CreateNoWindow {
  77. get {
  78. return(create_no_window);
  79. }
  80. set {
  81. create_no_window = value;
  82. }
  83. }
  84. [MonoTODO("Need to read the env block somehow")]
  85. [DesignerSerializationVisibility (DesignerSerializationVisibility.Content), DefaultValue (null)]
  86. [Editor ("System.Diagnostics.Design.StringDictionaryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  87. [MonitoringDescription ("Environment variables used for this process.")]
  88. public StringDictionary EnvironmentVariables {
  89. get {
  90. if (envVars == null) {
  91. envVars = new ProcessStringDictionary ();
  92. foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables ())
  93. envVars.Add ((string) entry.Key, (string) entry.Value);
  94. }
  95. return envVars;
  96. }
  97. }
  98. internal bool HaveEnvVars {
  99. get { return (envVars != null && envVars.Count > 0); }
  100. }
  101. [DefaultValue (false)]
  102. [MonitoringDescription ("Thread shows dialogboxes for errors.")]
  103. public bool ErrorDialog {
  104. get {
  105. return(error_dialog);
  106. }
  107. set {
  108. error_dialog = value;
  109. }
  110. }
  111. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
  112. public IntPtr ErrorDialogParentHandle {
  113. get {
  114. return(error_dialog_parent_handle);
  115. }
  116. set {
  117. error_dialog_parent_handle = value;
  118. }
  119. }
  120. [RecommendedAsConfigurable (true), DefaultValue ("")]
  121. [Editor ("System.Diagnostics.Design.StartFileNameEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  122. [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
  123. [MonitoringDescription ("The name of the resource to start this process.")]
  124. public string FileName {
  125. get {
  126. return(filename);
  127. }
  128. set {
  129. filename = value;
  130. }
  131. }
  132. [DefaultValue (false)]
  133. [MonitoringDescription ("Errors of this process are redirected.")]
  134. public bool RedirectStandardError {
  135. get {
  136. return(redirect_standard_error);
  137. }
  138. set {
  139. redirect_standard_error = value;
  140. }
  141. }
  142. [DefaultValue (false)]
  143. [MonitoringDescription ("Standard input of this process is redirected.")]
  144. public bool RedirectStandardInput {
  145. get {
  146. return(redirect_standard_input);
  147. }
  148. set {
  149. redirect_standard_input = value;
  150. }
  151. }
  152. [DefaultValue (false)]
  153. [MonitoringDescription ("Standart output of this process is redirected.")]
  154. public bool RedirectStandardOutput {
  155. get {
  156. return(redirect_standard_output);
  157. }
  158. set {
  159. redirect_standard_output = value;
  160. }
  161. }
  162. [DefaultValue (true)]
  163. [MonitoringDescription ("Use the shell to start this process.")]
  164. public bool UseShellExecute {
  165. get {
  166. return(use_shell_execute);
  167. }
  168. set {
  169. use_shell_execute = value;
  170. }
  171. }
  172. [DefaultValue ("")]
  173. [TypeConverter ("System.Diagnostics.Design.VerbConverter, " + Consts.AssemblySystem_Design)]
  174. [MonitoringDescription ("The verb to apply to a used document.")]
  175. public string Verb {
  176. get {
  177. return(verb);
  178. }
  179. set {
  180. verb = value;
  181. }
  182. }
  183. [MonoTODO]
  184. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
  185. public string[] Verbs {
  186. get {
  187. return(null);
  188. }
  189. }
  190. [DefaultValue (typeof (ProcessWindowStyle), "Normal")]
  191. [MonitoringDescription ("The window style used to start this process.")]
  192. public ProcessWindowStyle WindowStyle {
  193. get {
  194. return(window_style);
  195. }
  196. set {
  197. window_style = value;
  198. }
  199. }
  200. [RecommendedAsConfigurable (true), DefaultValue ("")]
  201. [Editor ("System.Diagnostics.Design.WorkingDirectoryEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  202. [TypeConverter ("System.Diagnostics.Design.StringValueConverter, " + Consts.AssemblySystem_Design)]
  203. [MonitoringDescription ("The initial directory for this process.")]
  204. public string WorkingDirectory {
  205. get {
  206. return(working_directory);
  207. }
  208. set {
  209. working_directory = value;
  210. }
  211. }
  212. }
  213. }