vb.net - 我无法弄清楚 ProcessStartInfo 并能够使用 Process.Start.StandardOutput.ReadToEnd 来显示命令行中发生的事情
问题描述
我试图在不打开命令行的情况下显示命令行界面中发生的事情。我知道 Process 类具有这种能力,但我很难使用 StandardOutput.ReadOnly。我将进程设置为一个按钮,然后单击后,我希望它显示命令行实际上正在连接的状态。想法?
Private Sub EstablishConnection_Click(sender As Object, e As EventArgs) Handles EstablishConnection.Click
' One file parameter to the executable
Dim sourceName1 As String = strXFileName
Dim sourceName2 As String = strYFileName
' New ProcessStartInfo created
Dim p As New ProcessStartInfo
' Specify the location of the binary
p.FileName = "C:\Software\John\Doe"
' Use these arguments for the process
p.Arguments = $"-Application -Connect -Example -E"" {stXFileName} "" -S"" {strYFileName} """
' Use a hidden window
p.WindowStyle = ProcessWindowStyle.Hidden
p.UseShellExecute = False
p.RedirectStandardOutput = True
p.RedirectStandardError = True
p.RedirectStandardInput = True
' Start the process
Process.Start(p)
'Dim output As String = p.StandardOutputEncoding
'Open the Status Screen form once connection is established
StatusScreen.Show()
Me.Hide()
End Sub
解决方案
推荐阅读
- embedded - RaspberryPi 4:udpsvd / qemu 的 tftp 启动问题
- powershell - 使用 PowerShell 模拟 Postman 请求失败
- android-studio - 如何使用按钮在android studio中打开/关闭移动数据?(应支持> = Android5.0)
- flutter - 脚手架钥匙 - 目的是什么以及在哪里使用
- traefik - Traefik 在控制台和文件上的访问日志
- docker - 是否可以在 docker-compose 中指定本地 .tar(docker image) 文件路径作为图像?
- node.js - 垃圾收集器会清除 NodeJs 中的全局变量属性吗?
- python - 我们可以在 react 应用程序中使用 plotly dash 应用程序吗?
- java - Gstreamer 在 JavaForm 上运行
- reactjs - React:更新 Firebase 适用于输入,不适用于选择