I have a python script which I can run via PowerShell using the following code:
cd User\PythonScripts
python TestFile.py
Now I want to run these simple commands via a PowerShell script (notepad file and saving it as a ps1 file).
I have googled a lot but I cannot find an answer, but I think it should be something like this:
$path = 'C:\User\PythonScripts'
$file = 'TestFile.py
I think I still miss the reference to python (so it knows which program he needs). How do I need to do this?
I think the question is you want to run the python script using powershell .
I think below code will do for you
$path = 'C:\User\PythonScripts'
$file = 'TestFile.py'
$cmd = $path+"\\"+$file # This line of code will create the concatenate the path and file
Start-Process $cmd # This line will execute the cmd
Save the above code as .ps1 and run the that powershell file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With