I thought it might be time to start using PowerShell
instead of cmd
. I currently run Python scripts from Notepad++ with the following commnad:
cmd /c cd "$(CURRENT_DIRECTORY)" &python -i "$(FILE_NAME)"
How should I modify this to get the same behaviour in PowerShell
please?
I tried
powershell -noexit cd "$(CURRENT_DIRECTORY)" &python -i "$(FILE_NAME)"
but I got an error about ampersands. I know very little about PowerShell
or cmd
in general - I just use them to run my Python scripts.
After a bit more digging I found a solution:
powershell -noexit cd '$(CURRENT_DIRECTORY)'; python -i '$(FILE_NAME)'
PowerShell
seems to prefer single quotes for paths so I wrapped $(CURRENT_DIRECTORY)
and $(FILE_NAME)
in single quotes.
Also, &
is replaced by ;
for multiple commands.
If there is a more "correct" way of doing this, please let me know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.