1 回答
TA贡献1777条经验 获得超10个赞
正如评论回复中所述,您在 using 语句的赋值中启动它一次,然后再向下几行。
您想使用默认构造函数,然后设置您需要的内容,然后启动它。在此处查看此示例(也粘贴在下面):
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
class MyProcess
{
public static void Main()
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.UseShellExecute = false;
// You can start any process, HelloWorld is a do-nothing example.
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
// This code assumes the process you are starting will terminate itself.
// Given that is is started without a window so you cannot terminate it
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the Kill method.
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
- 1 回答
- 0 关注
- 204 浏览
添加回答
举报