私は実行する必要があります
start cmd.exe /k "C:\Program Files (x86)\Mozilla Firefox\sdk\bin\activate & cd d:\home\name\addon\ & cfx run"
問題は、最初のパスにスペース ( Program Files
) があることです。引用符は既に完全なコマンドに使用されているため、使用できません。
このコマンドでスペースを使用するにはどうすればよいですか?
私は実行する必要があります
start cmd.exe /k "C:\Program Files (x86)\Mozilla Firefox\sdk\bin\activate & cd d:\home\name\addon\ & cfx run"
問題は、最初のパスにスペース ( Program Files
) があることです。引用符は既に完全なコマンドに使用されているため、使用できません。
このコマンドでスペースを使用するにはどうすればよいですか?
/ Cコマンドがすでに引用符で囲まれている場合、exeパスの前後に引用符を追加できないと誰が言いますか?それはうまくいきます!:-)
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つ以上の引用符が含まれているため、オプション2に従います。
上記が機能しないのは、exe名に&
たとえばのような特殊文字が含まれている場合のみthis&that.exe
です。STARTコマンドが最初に解析されるときにexe名が引用符で囲まれていないため、これにより問題が発生します。これは、ファイル名内の問題のある文字をエスケープすることで修正できます。
start cmd.exe /k ""this^&that.exe" & echo something else"
次のように、すべてのパス セグメントに最大 8 文字の古い DOS 書き込みスタイルを試すことができます。
C:\Progra~1\Mozill~1\
~1 はアルファベット順です。
C:\DisIsMyDirAlpha
C:\DisIsMyDirBeta
C:\DisIsMyDirGamma
これらは:
C:\DisIsM~1
C:\DisIsM~2
C:\DisIsM~3
最初のパスには引用符を使用し、次のようにエスケープします^
。
start cmd.exe /k "^"C:\Program Files (x86)\Mozilla Firefox\sdk\bin\activate^" & cd d:\home\name\addon\ & cfx run"
編集:
@dbenhamのコメントに関して:
興味深い。^
最初に頭に浮かんだコマンドでテストしたため、実際のコマンドは少し異なりましたが、エスケープはうまくいきました。
これは私のマシン(Windows XP SP 3)で動作します:
start cmd.exe /k "xcopy ^"C:\Program Files\Windows Live\Messenger\license.rtf^" c:\"
二重引用符を使用したエスケープについても読み""
ましたが、上記の例ではうまくいきませんでした。
繰り返しになりますが、私はバッチファイルの第一人者ではなく、cmd.exe
使用すると動作が異なる可能性があります&
(これまで聞いたことはありません)。
start cmd.exe /k "" "C:\Program Files (x86)\Mozilla Firefox\sdk\bin\activate & cd d:\home\name\addon\ & cfx run"
ファイルパスの前にこれら 2 つの余分な引用符を追加します。それは通常私にとってはうまくいきます。幸運を :)