samedi 28 mars 2015

Find out if process is running in a cmd.exe or PoweShell window

Imagine you're writing a program in a high level language where you are not allowed to do custom system calls (win32 API) because code is cross compiling or the language doesn't support that.


When your process is running on windows, is there a way to find out if you're running inside powershell and not cmd.exe? Or vice versa?


I'm trying to print "I'm running in powershell" and "I'm running in cmd.exe" from the program.


In this case I'm writing the program in Golang but that shouldn't really matter because I don't want to traverse process tree.


Aucun commentaire:

Enregistrer un commentaire