使用 System.Diagnostics.Process.Start 可輕鬆啟動本機可執行文件。本文提供 WinForm 按鈕點擊啟動計算器、媒體播放器、瀏覽器的最小化示例。
using System.Diagnostics;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1() { InitializeComponent(); }
private void btnCalc_Click(object sender, EventArgs e)
{
Process.Start("calc.exe"); // 計算器
}
private void btnPlayer_Click(object sender, EventArgs e)
{
Process.Start("TTPlayer.exe"); // 騰訊播放器(需安裝)
}
private void btnBrowser_Click(object sender, EventArgs e)
{
Process.Start("IEXPLORE.EXE"); // IE 瀏覽器
}
}
}
Process.Start("notepad.exe", "test.txt")Process p = Process.Start(...); 可監控退出碼、等待結束。p.StartInfo.Verb = "runas";p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false;