有人可以解释为什么当我开始这样的新流程时:
Dim pi2 As New ProcessStartInfo("cmd.exe", String.Format("/c ping 1.1.1.1 -n 1 -w 5000"))
pi2.CreateNoWindow = True
pi2.UseShellExecute = False
它隐藏了所谓的窗口,但是:
Dim pi2 As New ProcessStartInfo("cmd.exe", String.Format("/c ping 1.1.1.1 -n 1 -w 5000")) With {.CreateNoWindow = True And .UseShellExecute = False}
不隐藏窗口,为什么?
两个例子都不一样吗?
答案 0 :(得分:3)
此:
With {.CreateNoWindow = True And .UseShellExecute = False}
实际上只设置CreateNewWindow属性,并将其设置为UseShellExecute属性值的倒数。该代码实际上等同于:
pi2.CreateNoWindow = (True And pi2.UseShellExecute = False)
应该是:
With {.CreateNoWindow = True, .UseShellExecute = False}