Process.Start(screenreaderPath)没有停留在屏幕上

时间:2015-01-24 20:31:28

标签: vb.net

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
    Dim screenreaderPath As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "help.exe")
    Process.Start(screenreaderPath)

当我点击按钮时,它会加载但不会停留在屏幕上。相反,它只是消失了。任何人都可以解释原因吗?

1 个答案:

答案 0 :(得分:1)

由于这是一个命令行应用程序,您可以直接加载cmd.exe并将其传递给/ k参数,该参数告诉Windows让cmd保持打开状态:

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
    Dim screenreaderPath As String = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "help.exe")
    Dim oProcess As New Process
    Dim pi As ProcessStartInfo = New ProcessStartInfo()

    pi.Arguments = " /k """ & screenreaderPath & """"
    pi.FileName = "cmd.exe"
    oProcess.StartInfo = pi
    oProcess.Start()
End Sub