Question : how to run a batch file from an asp.net 2.0 web page?

Hello,

I am only a part time scripter and this is my first real website attempt.

I am using Visual Web Developer 2008 Express Edition to create an ASP.NET 2.0 Web Page.
I need the page to work in such a way that when a button is pressed, it runs either a batch file or a vbs file on the server.

I've got the design of the pages okay. However, I am having issues with the VB code that runs when the button is clicked. When I click the button on my local development pc, it runs fine and I can see the log file that is generated after the batch file runs. The batch file just runs ipconfig piped to a text file at the moment...

However, when I publish the web page onto a remote web server the script does not look like it runs and I do not get the logfile on the webserver c:\temp directory.

I have attached the code that works locally below. I got it from this previous post

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_21980453.html?sfQueryTermInfo=1+batch+file+from+how+page+run+vb.net+web

I also tried the variation in that post with the ExecuteBatchFile subroutine. For some reason I couldn't get it to work.

Hopefully someone can give me a helping hand with this.

Thanks in advance.

Joe
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Protected Sub btnTrainingRoom_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTrainingRoom.Click
        ' Define new process
        Dim procTrainingRoom As System.Diagnostics.Process

        ' Start the filename you have specified as this new process
        procTrainingRoom = System.Diagnostics.Process.Start("c:\temp\trainingroom.cmd")

        ' Wait for the batch file to finish
        procTrainingRoom.WaitForExit(1000)

    End Sub

Answer : how to run a batch file from an asp.net 2.0 web page?

you have to run & write permissions set up properly for this
check event viewer to see what errors you get...
Random Solutions  
 
programming4us programming4us