Web-Anwendung Asp.Net: Führen Sie einen Dos-Befehl

Ich habe eine web-Anwendung, wo ich will, um Befehle zu senden, um eine Befehlszeile (Kommandos nicht bekannt sind). Dies ist die Methode, die ich verwenden

    public static string ExecuteCommand(string command)
    {
        String result;
        try
        {
            //Create a new ProcessStartInfo
            System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
            //Settings
            procStartInfo.UseShellExecute = false;
            procStartInfo.CreateNoWindow = true;
            //Create new Process
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            //Set ProcessStartInfo
            proc.StartInfo = procStartInfo;
            //Start Process
            proc.Start();
            //Wait to exit
            proc.WaitForExit();
            //Get Result
            result = proc.StandardOutput.ReadToEnd();
            //Return
            return result;
        }
        catch
        {
        }
        return null;
    }

Der Befehl funktioniert auf einer Konsole-Anwendung, aber nicht auf eine web-Anwendung (null wird zurückgegeben)

    public string test = "NOTHING";

    protected void Page_Load(object sender, EventArgs e)
    {
        test = AppCommandHandler.ExecuteCommand("mkdir test2");
    }

Was mache ich falsch? Jedes tutorial schaue ich mir die mir sagt, zu verwenden ProcessStartInfo

Bearbeiten ich bekomme immer diese Fehlermeldung:

{"StandardOut wurde nicht umgeleitet, oder der Prozess hat noch nicht begonnen
doch."}

Schreibe einen Kommentar