c# - Determine whether Console Application is run from command line or Powershell -


how determine whether console application being run powershell or standard command line within application?

something might more reliable checking window title:

using system; using system.diagnostics;  process p = process.getcurrentprocess(); performancecounter parent = new performancecounter("process", "creating process id", p.processname); int ppid = (int)parent.nextvalue();  if (process.getprocessbyid(ppid).processname == "powershell") {   console.writeline("running in powershell"); } else {   console.writeline("not running in powershell"); } 

[source]


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -