close
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//'---------------------------
using System.Diagnostics; // for process class
using System.ComponentModel; //for Win32Exception class

// 詳細參考 http://www.dotblogs.com.tw/yc421206/archive/2009/04/18/8048.aspx

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//-----------------------------------------

foreach (Process p in System.Diagnostics.Process.GetProcessesByName("winword")) //找出有沒word 有就關掉
{
try
{
p.Kill();
p.WaitForExit(); // possibly with a timeout
}
catch (Win32Exception winException)
{
// process was terminating or can't be terminated - deal with it
}
catch (InvalidOperationException invalidException)
{
// process has already exited - might be able to let this one go
}
}

//-------------------------------------

}//endMain
}//end Program
}// ConsoleApplication1
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 prague12 的頭像
    prague12

    prague12

    prague12 發表在 痞客邦 留言(0) 人氣()