Microsoft
Software
Hardware
Network
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\config
1.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\filena
me.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\filena
me.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.Mas
ter" AutoEventWireup="false"
CodeBehind="Default.aspx.v
b" Inherits="WebApplication1.
_Default" %>
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ExecuteBatchFile("C:\inetp
ub\wwwroot
\config1.b
at")
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ExecuteBatchFile("C:\inetp
ub\wwwroot
\config2.b
at")
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ExecuteBatchFile("C:\inetp
ub\wwwroot
\config3.b
at")
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ExecuteBatchFile("C:\inetp
ub\wwwroot
\config4.b
at")
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(fil
ename)
' Wait for the batch file to finish
proc.WaitForExit()
End Sub
</script>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="Head
Content">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="Main
Content">
<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
Script to automatically delete files older than 1 month Windows NT server
How can i fill 1D array from 2D array and how can i sort 1D array?
Dynamic Color
Can't access Exchange 2003 OWA from Internet
Icon causing trouble with spell checker
Setting up FTP Users on IIS 7.5
User can't receive emails sent to her personal email, but emails to group get through...
Binary data
What hardware is best suited for "number crunching" web applications?
Remove security from MS Access Database (Jet Engine)