有小问题,哥们兄弟们看看啊。。呵呵。。有个高手教的,可调失败了using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Diagnostics;
namespace WebAppCSharpt
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
} /// <summary>
/// certificate test
/// </summary>
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string cmd = this.TextBox1.Text ;
if (cmd==null||cmd.Length==0)
return;
//输出执行命令的结果
Response.Write(this.RunCmd(cmd));
}
private void RunCmd(string strExec)
{
string rl;
Process p=new Process(); p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.WorkingDirectory="c:\\";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start(); p.StandardInput.WriteLine(strExec);
p.StandardInput.WriteLine("exit"); while((rl=p.StandardOutput.ReadLine())!=null)
{
Response.Write(p.StandardOutput.ReadLine());
}
} //把要执行的命令传进来就可以了,但是现在执行完不退出就有问题,必须执行一个命令退出一次,而且像ping这样的命令就打印不出来,建议最好把要执行的命令一行写完,执行一次。因为退出以后再执行的命令还是在默认目录下的。
}
}
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Diagnostics;
namespace WebAppCSharpt
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
} /// <summary>
/// certificate test
/// </summary>
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string cmd = this.TextBox1.Text ;
if (cmd==null||cmd.Length==0)
return;
//输出执行命令的结果
Response.Write(this.RunCmd(cmd));
}
private void RunCmd(string strExec)
{
string rl;
Process p=new Process(); p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.WorkingDirectory="c:\\";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start(); p.StandardInput.WriteLine(strExec);
p.StandardInput.WriteLine("exit"); while((rl=p.StandardOutput.ReadLine())!=null)
{
Response.Write(p.StandardOutput.ReadLine());
}
} //把要执行的命令传进来就可以了,但是现在执行完不退出就有问题,必须执行一个命令退出一次,而且像ping这样的命令就打印不出来,建议最好把要执行的命令一行写完,执行一次。因为退出以后再执行的命令还是在默认目录下的。
}
}
解决方案 »
- 一个关于用visual studio 2010 进行web开发的问题
- aspx页面转为pdf 求助
- 请问,如何在两个表格之间移动行并能用托懂行的办法在表内排序
- 求教.net里使用jquery ajax的方法
- SQL 中 的case ....when 判断为null 的做方法是什么?????
- 帮忙看看为什么错了:未将对象引用设置到对象的实例
- 图片上传的问题,搞了两天没看出什么问题
- JavaScript如何取得Label的值?
- 急!FreeTextBox 和 showModalDialog 的结合使用问题。
- 要建站点地图效果图如图 下图是我建的 不知道对不对 还有没有其他步骤了
- ◆◆◆ WriteEntry问题 ◆◆◆
- 非常好的博客网站 http://www.cnblogs.com/
F:\x_asedo\复件 WebApplication3\WebForm1.aspx.cs(67): 参数“1” : 无法从“void”转换为“string”
以上是错误信息
Response.Write(this.RunCmd(cmd));
错了吧。
RunCmd(string strExec)
没返回值的!!!
--------------------------------------------------------------------------------Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.Source Error:
Line 44: 它为成员站点提供单独登录和核心配置文件服务。
Line 45: -->
Line 46: <authentication mode="Windows" />
Line 47:
Line 48: <!-- 授权
Source File: F:\x_asedo\复件 WebApplication3\web.config Line: 46
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.42; ASP.NET Version:2.0.40607.42
wf5360308(峰
根据你的回答我改了,成功,可是访问时就这样了。。
{
string rl;
Process p=new Process(); p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.WorkingDirectory="c:\\";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start(); p.StandardInput.WriteLine(strExec);
p.StandardInput.WriteLine("exit");
string str=""; while((rl=p.StandardOutput.ReadLine())!=null)
{
str+=p.StandardOutput.ReadLine().ToString ();
}
return str; } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string cmd = this.TextBox1.Text ;
if (cmd==null||cmd.Length==0)
return;
//输出执行命令的结果
TextBox2.Text =this.RunCmd(cmd); }
就是让你在IIS为你的应用创建一下虚拟目录。兄弟
中文版的错误信息:
配置错误
说明: 在处理向该请求提供服务所需的配置文件时出错。请检查下面的特定错误详细信息并适当地修改配置文件。 分析器错误信息: 在应用程序级别以外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。导致该错误的原因可能是在 IIS 中没有将虚拟目录作为应用程序进行配置。源错误:
行 36: “Passport”和“None”
行 37: -->
行 38: <authentication mode="Windows" />
行 39:
行 40: <!-- 应用程序级别跟踪记录
源文件: d:\inetpub\wwwroot\AYSTAdmin\web.config 行: 38
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Diagnostics; //这个引用要加
namespace WebAppCSharpt
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
} /// <summary>
/// certificate test
/// </summary>
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.TextBox2.TextChanged += new System.EventHandler(this.TextBox2_TextChanged);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion //private void Button1_Click(object sender, System.EventArgs e)
//{
//string cmd = this.TextBox1.Text ;
// if (cmd==null||cmd.Length==0)
// return;
//输出执行命令的结果
//Response.Write(this.RunCmd(cmd)); // this.RunCmd(cmd);
//}
private string RunCmd(string strExec)
{
string rl;
Process p=new Process(); p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.WorkingDirectory="c:\\";
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start(); p.StandardInput.WriteLine(strExec);
p.StandardInput.WriteLine("exit");
string str=""; while((rl=p.StandardOutput.ReadLine())!=null)
{
str+=p.StandardOutput.ReadLine().ToString ();
}
return str; }
private void Button1_Click(object sender, System.EventArgs e)
{
string cmd = this.TextBox1.Text ;
if (cmd==null||cmd.Length==0)
return;
//输出执行命令的结果
TextBox2.Text =this.RunCmd(cmd); }
//把要执行的命令传进来就可以了,但是现在执行完不退出就有问题,必须执行一个命令退出一次,而且像ping这样的命令就打印不出来,建议最好把要执行的命令一行写完,执行一次。因为退出以后再执行的命令还是在默认目录下的。
}
}
加了一个文本框,可是依然错的
“WebAppCSharpt.WebForm1”并不包含对“TextBox2_TextChanged”的定义
你的TextBox2_TextChanged方法呢?被删了吧。如果没有用,就把上面的这一行也删掉。
告诉我你的msn吧
http://218.27.204.17/aspnet/a_user.aspx
(C) 版权所有 1985-2001 Microsoft Corp.c:\>net user\\ASEDO-3 的用户帐户-------------------------------------------------------------------------------ASPNET Guest HelpAssistant SQLDebugger SUPPORT_388945a0 WADM_ASEDO-3 c:\>exit
也就是说命令输出结果不全啊老是一半。。本来在文本框2里应该成功的,可是还是失败了。。