Process对象必须将UseShellExecute属性设置为False才能使用环境变量解决办法

加下面两行
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;

The reason being that the key setting is CreateNoWindow which has to be true. But CreateNoWindow only has any effect when UseShellExecute is false. That’s because CreateNoWindow maps to the CREATE_NO_WINDOW process creation flag passed to CreateProcess. And CreateProcess is only called when UseShellExecute is false.

More information can be found from the documentation:

Property Value

true if the process should be started without creating a new window to contain it; otherwise, false. The default is false.

Remarks

If the UseShellExecute property is true or the UserName and Password properties are not null, the CreateNoWindow property value is ignored and a new window is created.

    原文作者:Acettest
    原文地址: https://blog.csdn.net/u010178308/article/details/88535563
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞