Ответ 1
Кто сказал, что вы не можете добавлять кавычки по пути exe, когда команда /C уже цитируется? Он отлично работает!: -)
start cmd.exe /k ""C:\Program Files (x86)\Mozilla Firefox\sdk\bin\activate" & cd d:\home\name\addon\ & cfx run"
Внешние кавычки вокруг команды /C удаляются перед выполнением, оставляя только кавычки вокруг вашего пути exe. Вы можете прочитать о том, как CMD-процесс цитируется в справочной системе. Просто введите CMD /?
или HELP CMD
из командной строки. Это запутывает.
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:
1. If all of the following conditions are met, then quote characters
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
Ваша команда имеет более двух кавычек, поэтому требуется опция 2.
Единственный раз, когда указанное выше не будет работать, - это если ваше имя exe содержит специальный символ, например &
, например this&that.exe
. Это вызывает проблему, потому что имя exe не цитируется, когда команда START изначально анализируется. Это можно устранить, экранируя символ проблемы в имени файла.
start cmd.exe /k ""this^&that.exe" & echo something else"