Question : How to execute multiple batch files OnClick with VB script within ASP.Net webpage

I have put together a simple website on local PC, Window7, running on IIS 7. I have spent a LOT of time trying to finish this project and I am on the brink of pulling out the remander of my hair.  I have 10 buttons on a webpage upon clicking one of the buttons it executes a batch file located in c:\inetpub\wwwroot\ , the batch file kicks off a powershell command:
@echo off
powershell -command "& {C:\inetpub\wwwroot\config1.ps1}"
the reason why I need the powershell command is to talk to COM1 and COM2 and this is the only thing that has work consistently. I also have in the batch file a CALL “c:\inetpub\wwwroot\filename.bat” . Everything works perfectly when I launch it from within the folder, from shortcut on desktop, but when I launch it from the webpage everything works except the last CALL “c:\inetpub\wwwroot\filename.bat”
I am a novice at all of this and have searched and extinguished almost all my resources. I am so close to finishing this project but need some help.
Default.aspx file:                  I know that this is only 4 buttons, this is my test file.
<%@ Page Title="Zotec War Room" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

    <script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            ExecuteBatchFile("C:\inetpub\wwwroot\config1.bat")
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            ExecuteBatchFile("C:\inetpub\wwwroot\config2.bat")
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            ExecuteBatchFile("C:\inetpub\wwwroot\config3.bat")
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            ExecuteBatchFile("C:\inetpub\wwwroot\config4.bat")
    End Sub
   
        Private Sub ExecuteBatchFile(ByVal filename As String)
            ' Define a new process
            Dim proc As System.Diagnostics.Process

            ' Start tge filename you have specified as this new process
            proc = System.Diagnostics.Process.Start(filename)

            ' Wait for the batch file to finish
            proc.WaitForExit()
        End Sub
</script>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
   
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Height="150px" Text="5 Monitors"
        Width="150px" />
    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Height="150px" Text="Dual Monitors"
        Width="150px" />
    <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Height="150px" Text="One Moitor"
        Width="150px" />
    <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Height="150px" Text="TV"
        Width="150px" />
   
</asp:Content>

Answer : How to execute multiple batch files OnClick with VB script within ASP.Net webpage

Ofcourse... just use Process.Start twice.
Random Solutions  
 
programming4us programming4us