Results 1 to 3 of 3

Thread: Call a batch file from a command button...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2012

    Call a batch file from a command button...

    Hi all, I am very new to VB, and I have a button that I want to execute a command (batch file) from a file location, and once it launches the batch file I would like my VB program to close... Lets call the file CommandScript.cmd and the location is C:\MyFile

        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    ' Where the file is called and executed...this is where I am completely stuck
        End Sub
    End Class

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Providence, RI - USA

    Re: Call a batch file from a command button...

    You can start a process to run the batch file and then close your application.
    Process.Start("full path to the batch file here")
    Me.Close() '<<< Use this if your button is on the main form
    Application.Exit '<<< Or use this if your button is not on the main form.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012

    Re: Call a batch file from a command button...

    To open the bat file ...


    To close the VB program ... well, that's a matter of some dispute.


    .. is the quick and dirty method but you'll find at least a dozen different opinions on whether it's the best!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width