在运行进程时隐藏vb.net中的命令窗口

时间:2012-08-02 16:12:10

标签: asp.net vb.net command-prompt

如果我有这段代码

    ' Send file to Unix server via pscp
    Dim Proc As New System.Diagnostics.Process
    Proc.StartInfo = New ProcessStartInfo("C:\Windows\System32\cmd.exe")
    Proc.StartInfo.Arguments = "/C C:\pscp.exe -pw " & PASSWORD & " " & physicalFolder & "\" & UNIXSCRIPTNAME & " " & unixLogin
    Proc.StartInfo.RedirectStandardInput = True
    Proc.StartInfo.RedirectStandardOutput = False
    Proc.StartInfo.UseShellExecute = False
    Proc.Start()
    ' Allows script to execute sequentially instead of simultaneously
    Proc.WaitForExit()

执行此操作时,如何才能显示命令窗口? 谢谢!

2 个答案:

答案 0 :(得分:4)

你可以通过将CreateNoWindow设置为true来实现,这可能会有所帮助MSDN

Proc.StartInfo.CreateNoWindow = true

答案 1 :(得分:1)

CreateNoWindow = True 对我不起作用,以下工作完美:

Proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden