我试图打开Server管理演播室,在编程上,我使用 process 打开Server,并使用Start()方法打开进程,
using System.Diagnostics;
Process Sql = new Process();
string strfile1="example1.sql";
string strfile2="example2.sql";
Sql.StartInfo.FileName = "Ssms.exe";//sql server process
Sql.StartInfo.Arguments = strfile1;
Sql.Start();
Sql.StartInfo.Arguments = strfile2;
Sql.Start();这段代码打开了两个server实例,但是我想检查进程是否已经在运行,并重用现有的进程,并在同一个Process.How中打开example2.sql,这能做到吗?
发布于 2013-03-21 08:04:51
您可以检查进程是否按名称运行(需要查找ssms进程的名称),如下所示:
Process[] procName= Process.GetProcessesByName("INSERT NAME HERE");
if (procName.Length >= 0)
{
//you are already running
}但我认为您将无法修改现有的ssms实例。
发布于 2013-03-21 08:13:52
如果你让操作系统来决定该做什么呢?
Process.Start("example1.sql");
Process.Start("example2.sql");https://stackoverflow.com/questions/15542126
复制相似问题