Run batch file in vb.net?

前端 未结 4 414
臣服心动
臣服心动 2020-11-27 06:58

How can I run a batch from from within vb.net?

相关标签:
4条回答
  • 2020-11-27 07:27

    Simple and straight forward method

    System.Diagnostics.Process.Start("c:\batch.bat")

    0 讨论(0)
  • 2020-11-27 07:36

    'The easiest way if you know the exact location of the file is

    System.Diagnostics.Process.Start("c:\test\file.bat")

    'In Visual Studio the file must exist in the /bin/debug or /bin/release depending on your current build configuration

    System.Diagnostics.Process.Start("test.bat")

    0 讨论(0)
  • 2020-11-27 07:42

    The best way is to use the Process.Start and pass the path to the batch file

    Process.Start(pathToBatchFile)
    
    0 讨论(0)
  • 2020-11-27 07:43

    You can use the Process class to run a batch file

    Dim psi As New ProcessStartInfo("Path TO Batch File")
    psi.RedirectStandardError = True
    psi.RedirectStandardOutput = True
    psi.CreateNoWindow = False
    psi.WindowStyle = ProcessWindowStyle.Hidden
    psi.UseShellExecute = False
    
    Dim process As Process = Process.Start(psi)
    
    0 讨论(0)
提交回复
热议问题