获取或设置一个值,该值指示是否使用操作系统外壳程序启动进程。

命名空间:System.Diagnostics
程序集:System(在 system.dll 中)

语法

 
 
 
public bool UseShellExecute { get; set; }
 
/** @property */
public boolean get_UseShellExecute () /** @property */
public void set_UseShellExecute (boolean value)
 
public function get UseShellExecute () : boolean

public function set UseShellExecute (value : boolean)

属性值

若要在启动进程时使用外壳程序,则为 true;否则,直接从可执行文件创建进程。默认为 true

备注

 
 

将此属性设置为 false 使您能够重定向输入流、输出流和错误流。

注意

如果 UserName 属性不为 空引用(在 Visual Basic 中为 Nothing) 或不是一个空字符串,则 UseShellExecute 必须为 false,否则调用Process.Start(ProcessStartInfo) 方法时将引发 InvalidOperationException

使用操作系统外壳程序启动进程时,您能够使用 Process 组件启动任何文档(可以是任何与可执行文件关联的、拥有默认打开操作的注册文件类型),并对该文件执行操作(如打印)。当 UseShellExecute 为 false 时,使用 Process 组件仅能启动可执行文件。

注意

如果将 ErrorDialog 属性设置为 true,则 UseShellExecute 必须为 true

WorkingDirectory 属性的行为在 UseShellExecute 为 true 并当 UseShellExecute 为 false 时是不同的。当 UseShellExecute 为 true时,WorkingDirectory 属性指定可执行文件的位置。如果 WorkingDirectory 是空字符串,则认为当前目录包含可执行文件。

当 UseShellExecute 为 false 时,不使用 WorkingDirectory 属性查找可执行文件。相反,它被已启动的进程使用,并且只在新进程的上下文中有意义。

示例

 
 
 
Process compiler = new Process();
compiler.StartInfo.FileName = "csc.exe";
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start(); Console.WriteLine(compiler.StandardOutput.ReadToEnd()); compiler.WaitForExit();

最新文章

  1. XNA游戏编程等
  2. ECMall /app/buyer_groupbuy.app.php SQL Injection Vul
  3. Android高性能ORM数据库DBFlow入门
  4. H5-考试判断题
  5. python中时间的基本使用
  6. detain ssh server 设置
  7. 走出 null 就是空值的误区,以及变量赋值原理
  8. AsyncTask 与 Thread+Handler
  9. AfxGetMainWnd()函数用法
  10. nginx.conf配置
  11. 什么是JSONP以及它是怎么产生的
  12. 【Deep Learning】genCNN: A Convolutional Architecture for Word Sequence Prediction
  13. leetcode 9 Palindrome Number 回文数
  14. .net调用系统软键盘(兼容win7及win10)
  15. Java关键字(一)——instanceof
  16. Paired t-test
  17. Dockerfile 构建后端tomcat应用并用shell脚本实现jenkins自动构建
  18. [leetcode]113. Path Sum II路径和(返回路径)
  19. .NET中查看一个强命名程序集(*****.dll)的PublicKeyToken的方法
  20. 【转】Nginx反向代理转发tomcat

热门文章

  1. PV 并发量的计算
  2. OLEDB读取EXCEL表格时,某些字段为空,怎么办?
  3. 【JAVA错误笔记】 - Unable add facets project AnnotationWebService CXF 2-x Web Services
  4. C#对于sql server数据库的简单操作
  5. 关于layoutSubviews以及drawRect方法
  6. String类与Date类的转换
  7. mysql 查找包含特定名字的表
  8. jquery禁用a标签,jquery禁用按钮click点击
  9. PHPCMS二次开发教程
  10. php提取背景图片