0

Hi


I need a vb.net example code to execute a batch file when a button is clicked in my application .. The .bat file is in a different location and it must be called and executed.... Thanks in advance..

3
Contributors
4
Replies
8
Views
7 Years
Discussion Span
Last Post by jaimca
Featured Replies
  • 1
    sknake 1,622   7 Years Ago

    [code] Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim p As New System.Diagnostics.Process() p.StartInfo.FileName = "C:\\test.bat" p.Start() End Sub [/code] You can also call [icode]p.WaitForExit()[/icode] if you want your application to hold up until the bat file is done running. Read More

  • Try out this: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim p As New Process() p.StartInfo.FileName = "E:\Users\Tom\Desktop\test.bat" p.StartInfo.WindowStyle = ProcessWindowStyle.Normal p.Start() p.WaitForExit() p.Close() MessageBox.Show("App closed now") End Sub Read More

1
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		Dim p As New System.Diagnostics.Process()
		p.StartInfo.FileName = "C:\\test.bat"
		p.Start()
	End Sub

You can also call p.WaitForExit() if you want your application to hold up until the bat file is done running.

1

Try out this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As New Process()
p.StartInfo.FileName = "E:\Users\Tom\Desktop\test.bat"
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal
p.Start()
p.WaitForExit()
p.Close()
MessageBox.Show("App closed now")
End Sub

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.