As per my earlier comment, if you had read the Command Prompt output of the usage information for the start
command, you'd have noticed that the first double-quoted string is parsed as the window title; i.e.
C:\users\TaihouKai>start /?
Starts a separate window to run a specified program or command.
START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
[command/program] [parameters]
"title" Title to display in window title bar.
path Starting directory.
…
So when you use start "%cd%\python\python.exe" main.py
your code is running start main.py
, with the Window Title %cd%\python\python.exe
.
This means that their system looks for whatever application is configured to run .py
files. If they already have an executable file, (most likely python.exe
) registered, it will use that, if they don't it will trigger the 'Choose an application…' prompt.
What you need therefore is a title, even an empty one, to prevent that parsing issue of the first double-quoted string.
@SetLocal EnableExtensions
@CD /D "%~dp0"
@Start "" "%CD%\python\python.exe" main.py
Although, in your case, as you have a known directory structure, and it does not include any characters which require double-quoting, I'd say that you could probably do it like this:
@SetLocal EnableExtensions
@CD /D "%~dp0"
@Start python\python.exe main.py
Alternatively you could use the /D
option for start
to predefine the working directory:
@SetLocal EnableExtensions
@Start "" /D "%~dp0." "%~dp0python\python.exe" "main.py"
This final example encloses all strings with double-quotes as a robust, rule of thumb, safety habit.