E
E
Evgeny Kotov2019-11-14 16:33:51
ASP.NET
Evgeny Kotov, 2019-11-14 16:33:51

How to run *.bat on the server using ASP?

Ideally, I would like a web face that runs a script with a parameter on the server
by pressing a button
like this
test.aspx

<%@ Page Language="C#" CodeFile="test.aspx.cs" Inherits="_Default" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Hallo Welt</title>
</head>
<body>
    <form id="halloForm" runat="server">
        Parametr: <asp:TextBox id="TbName" runat="server" />
        <br />
        <asp:Button ID="ButtonOk" Text="Test" runat="server" OnClick="ButtonOk_Click" />
        <br />
        <asp:Label ID="LabelHallo" runat="server"/>
    </form>
</body>
</html>

testaspx.cs
using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.ComponentModel;

public partial class _Default : System.Web.UI.Page
{
    protected void ButtonOk_Click(object sender, EventArgs e)
    {
        Process.Start("C:\\Temp\\script.bat");
    }
}


только незнаю как правильно синтаксически передать переменную
что бы получилось так

C:\Temp\script.bat переменная из формы

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yuopi, 2019-11-14
@yuopi

https://docs.microsoft.com/ru-ru/dotnet/api/system...

E
Evgeny Kotov, 2019-11-25
@eskotov

Process.Start("C:\\Temp\script.bat", TbNname.Text);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question