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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -