If you add .PY to the .PY environment PATHEXT , you should be able to run .\hello.py or just .\hello in the current console. Otherwise, it will be a ShellExecute related Python.File command (check ftype Python.File ), which launches a new console. I checked this by temporarily changing the environment variable:
$env:pathext = $env:pathext + ";.PY"
source share