Wednesday, March 14, 2007

Run a batch file through ASP.NET


This is a sample program for running a batch file using asp.net


Imports System.Diagnostics

Partial Class testing
Inherits System.Web.UI.Page

Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As New ProcessStartInfo
p.WorkingDirectory = "c:\"
p.FileName = "p.bat"
p.UseShellExecute = True
Process.Start(p)
End Sub
End Class

Create "p.bat" and a.txt file in C directory and "p.bat" file contains the following code

ren a.txt b.txt
pause

1 comment:

Anonymous said...

Well written article.