private void UpdateProcessList()
{
// clear the existing list of any items
listBox1.Items.Clear();
// loop through the running processes and add
//each to the list
foreach (System.Diagnostics.Process p in
System.Diagnostics.Process.GetProcesses())
{
listBox1.Items.Add(p.ProcessName + " - " + p.Id);
}
// display the number of running processes in
// a status message at the bottom of the page
listBox1.Text = "Processes running: " +
listBox1.Items.Count.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
ProcessStartInfo pi = new ProcessStartInfo();
pi.Verb = "runas";
pi.FileName = "1-AccountServer.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
pi.FileName = "2-DatabaseServer.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
pi.FileName = "3-CoreServer.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
pi.FileName = "4-CacheServer.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
pi.FileName = "5-Certifier.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
pi.FileName = "6-LoginServer.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
pi.FileName = "7-WorldServer.exe";
pi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(pi);
Thread.Sleep(10000);
}
问题是我不希望每个流程都显示,而只是这七个特定流程,我该怎么做?它确实有效,但不是我真正想要的方式>。<我在互联网上搜索了一段时间以实际找到这段代码并将其实现为我想要的,但它只是显示了这么多我想要的过程因为是没有意义的。