How can I detect whether or not I am in powershell from a command line? -


i creating standard windows bat/cmd file , want make if statement check whether or not cmd file run powershell. how can that?

edit: underlying problem test.cmd "a=b" results in %1==a=b when run cmd %1==a , %2==b when run powershell. script run old windows command line script in both cases, checking get-childitem yield error.

one way, see process name is, , check attributes:

title=test tasklist /v /fo csv | findstr /i "test" 

as long use unique name in place of test, there should little room error.

you like:

"cmd.exe","15144","console","1","3,284 k","running","gncid6101\athomsfere","0:00:00","test"

when ran above code bat file, output was:

"powershell.exe","7396","console","1","50,972 k","running","gncid6101\athomsfere","0:00:00","


Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -