gpt4 book ai didi

VB.NET 读取标准输出

转载 作者:行者123 更新时间:2023-12-01 11:56:35 25 4
gpt4 key购买 nike

我需要从我的应用程序运行命令并解析输出。我可以毫无问题地执行此操作,但我不想显示命令。我希望 WindowStyle = ProcessWindowStyle.Hidden 会起作用,但它不起作用。以下面的示例代码为例。它工作正常,但命令窗口仍然明显打开和关闭得非常快,我需要它永远不要露出丑陋的面孔。我该如何解决这个问题?

Dim myprocess As New Process
Dim lines As String = ""

With myprocess
.StartInfo.FileName = "C:\Windows\System32\cmd.exe"
.StartInfo.Arguments = "/c ipconfig"
.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
.StartInfo.RedirectStandardOutput = True
.StartInfo.UseShellExecute = False
.Start()
End With

lines = myprocess.StandardOutput.ReadToEnd

MsgBox(lines)

最佳答案

也尝试将 CreateNoWindow 设置为 True

如果您想要实现的是找到本地机器的 IP 地址,则有 more direct ways of doing it .

关于VB.NET 读取标准输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6538799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com