Is it possible to determine which process starts my .Net application?

Question :

Is it possible to determine which process starts my .Net application?,

Answer :

I am developing console application in .Net and I want to change a behavior a little based on information that application was started from cmd.exe or from explorer.exe. Is it possible?

,

Process this_process = Process.GetCurrentProcess();  int parent_pid = 0;  using (ManagementObject MgmtObj = new ManagementObject("win32_process.handle='" + this_process.Id.ToString() + "'"))  {      MgmtObj.Get();      parent_pid = Convert.ToInt32(MgmtObj["ParentProcessId"]);  }  string parent_process_name = Process.GetProcessById(parent_pid).ProcessName;  

That’s the answer Is it possible to determine which process starts my .Net application?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Scrum – How to get better input from the functional/commercial team

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you