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;

  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 ();   

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:

  process [] ProcName = process GetProcessesByName ("Enter name here"); If (procName.Length & gt; = 0) {// you are already running}   

but I do not think you are able to modify an existing instance of ssms again Will be / P>

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -