c# - Bind to Existing Process -
I'm trying to open SQL Server Management Studio, programmatically, I started the process to open SQL is used by the server and the start () method to open the process; This code opens up two examples of SQL Server, but I want to check if the process is already running and reuse the existing process and in the same process example2.sql Opens. How could this be done? You can check that a process is running by name (you need to know the name of your SSMS Is the process) in this way: but I do not think you are able to modify an existing instance of ssms again Will be / P>
using System.Diagnostics; Process Sql = New Process (); String Strawfill 1 = "Example 1 SQL"; String Strings 2 = "Example 2.sql"; Sql.StartInfo.FileName = "Ssms.exe"; // SQL Server Process Sql.StartInfo.Arguments = strfile1; Sql.Start (); Sql.StartInfo.Arguments = strfile2; Sql.Start ();
process [] ProcName = process GetProcessesByName ("Enter name here"); If (procName.Length & gt; = 0) {// you are already running}
Comments
Post a Comment