-
Jul 2nd, 2012, 01:19 PM
#1
Thread Starter
New Member
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
Code:
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
-
Jul 2nd, 2012, 01:41 PM
#2
Re: Call a batch file from a command button...
You can start a process to run the batch file and then close your application.
Code:
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 -
-
Jul 2nd, 2012, 01:55 PM
#3
Re: Call a batch file from a command button...
To open the bat file ...
Process.Start("C:\MyFile\CommandScript.cmd")
To close the VB program ... well, that's a matter of some dispute.
Application.Exit
.. 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|