To run Python files (.py) with Windows CMD.exe, I SHIFT + Right Click on my project folder which contains all of my Python code files. Doing this shows a menu containing the option Open command window here
, which I click to open CMD.exe with the prompt C:\\Users\\Name\\FolderLocation\\ProjectFolder>
. I then type the python command, and the file I want to run in my project folder ( python MyFile.py
) which runs the file, of course.
What I would like to know is if there is a way I can setup a shortcut to open CMD.exe with my project folder opened/ being accessed so then all I have to do is type python and the file name? Thanks
Create a shortcut to cmd.exe.
Get properties on that shortcut, and there's an entry for the current working directory. (They change the name of that field every other version of Windows, but I believe most recently it's called "Start In:".) Just set that to C:\\Users\\Name\\FolderLocation\\ProjectFolder
.
Now, when you double-click that shortcut, it'll open a cmd.exe window, in your project directory.
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.