user225269
user225269

Reputation: 10913

how to incorporate a batch file with vb.net

I'm currently using this method in calling batch files in vb.net:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        System.Diagnostics.Process.Start("F:\ipconfigflushdns.bat")
    End Sub

Is it possible to incorporate the code written in the batch file so that I won't have to call it like the one above?

Upvotes: 2

Views: 868

Answers (1)

Jason Kresowaty
Jason Kresowaty

Reputation: 16500

Yes, what you have shown will work. However, I would recommend that you rename your batch file with .cmd extension. This is more proper on Windows and causes there to be no ambiguity as to whether the 32-bit/64-bit Windows cmd.exe or the 16-bit MS-DOS compatibility command.com should be used loaded.

See: Windows batch files: .bat vs .cmd?

Is it possible to incorporate the code written in the batch file so that I won't have to call it like the one above?

Sure, it is possible. You'll need to take the typical approach for porting a program from one language to a very different one. That is, read the batch file and figure out manually how to do the same things using the .NET Framework.

Upvotes: 2

Related Questions