How to make a batch file run in vscode terminal
You are mixing batch files and powershell. Those are two separate things. Batch files suffix can be either .bat
or .cmd
. The powershell files end usually with .ps1
.
Batch files are using the C:\WINDOWS\system32\cmd.exe
. Powershell is using the C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
. As you can see those are two different interpreters.
If you need to run a .ps1
file that is a powershell script you need to run it in powershell not a .bat
file!
To execute your script you need to execute it like this:
& 'C:\env\Scripts\activate.ps1'
If you run it at powershell your if condition will not work anymore. You need to do something like this:
$PipArgs = @('install', 'virtualenv') if(Test-Path -PathType leaf "C:\env"){ & 'pip3' $PipArgs & 'virtualenv' 'env'}