public int GetProcessId(string pName) { var pList = Process.GetProcessesByName(pName); if(pList.Length > 0) return rList[0].Id; else return -1; }