Search code examples
pythonpowershellbatch-filecommandcygwin

Changing called command in Powershell


I am trying to run a bat script via Powershell that uses Python calls, using Cygwin's Python. The script is pre-made (i.e. not mine) and rather large, but since it invokes python, rather than python.exe calls, it does not execute properly, since the proper command would be python27.exe. How can I change that in Powershell?


Solution

  • I guess you can create an alias for that in your PowerShell script or profile. Something like below could be an option for you (include this at the top of your PowerShell script, before the first call to python):

    New-Alias -Name python -Value "C:\Program Files\Python\Python27.exe"
    

    Also check in help in PowerShell itself for this.

    Get-Help about_alias
    

    https://technet.microsoft.com/en-us/library/hh849959.aspx