Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29908
  • 博文数量: 11
  • 博客积分: 346
  • 博客等级: 一等列兵
  • 技术积分: 205
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-14 16:20
文章分类
文章存档

2012年(11)

我的朋友
最近访客

分类: 嵌入式

2012-08-07 10:26:37

因公司内网服务器的软加密服务进程会不定时的卡死,需要手工关闭进程再启动,每次出现类似问题总要用远程服务器或者进入机房操作机器,但有时是晚上不是很方便,健康知识平台但远程的密码和机房钥匙又不方便给他人,因此想到以下解决方法。
 
    做一个BAT批处理文件来通过stop/start来关闭和启动服务,正好服务器上已有IIS+.NET2.0,就写了一个aspx页面,让员工发现无法使用时,通过访问该网页点击bottom事件执行BAT文件来解决。
 
    以下是C#源代码
 
    using System;
 
    using System.Collections.Generic;
 
    using System.Web;
 
    using System.Web.UI;
 
    using System.Web.UI.WebControls;
 
    namespace WebApplication3
 
    {
 
    public partial class _Default : System.Web.UI.Page
 
    {
 
    protected void Page_Load(object sender, EventArgs e)
 
    {
 
    }
 
    protected void Button1_Click(object sender, EventArgs e)
 
    { http://lailjiaaie.blog.51cto.com
 
    System.Diagnostics.ProcessStartInfo pro = new System.Diagnostics.ProcessStartInfo("cmd.exe");
 
    pro.UseShellExecute = false;
 
    pro.RedirectStandardOutput = true;
 
    pro.RedirectStandardError = true;
 
    pro.Arguments = "/K D:\\jiamiError\\test.bat";
 
    pro.WorkingDirectory = "D:\\jiamiError\\";
 
    System.Diagnostics.Process proc = System.Diagnostics.Process.Start(pro);
 
    System.IO.StreamReader sOut = proc.StandardOutput;
 
    proc.Close();
 
    string results = sOut.ReadToEnd()。Trim();
 
    sOut.Close();
 
    string fmtStdOut = "{0}";
 
    this.Response.Write(String.Format(fmtStdOut, results.Replace(System.Environment.NewLine, "
")));
 
    /*Response.Write("");*/
 
    /*Response.Redirect("Success.html");*/
 
    }
 
    }
 
    }
阅读(517) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~