2011-01-20 23 views
1

私はappcmd.exeを実行する必要がありますが、cmd.exeを実行してIIS Webサイトを照会し、出力をリダイレクトする必要があります。引用符を引用符で囲んでcmd.exe

コマンドは次のようになります。これは正常に動作します

cmd /c "c:\windows\system32\inetsrv\appcmd.exe list site MySite" > c:\output.txt 

私は引用符を使用する必要があり、その場合には、私のパス内のスペースを、持っているときは、しかし、私は、問題が発生しました。理想的には、私はやります:

cmd /c ""c:\windows\system32\inetsrv\appcmd.exe" list site "MySite"" > "c:\output.txt" 

しかし、これは動作しません - 任意のアイデア?

答えて

0
cmd /c c:\windows\system32\inetsrv\appcmd.exe list site MySite > c:\output.txt 
0

これはうまくいくかもしれない:

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 
     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で述べた "古い" 行動:

cmd /c "'c:\windows\system32\inetsrv\appcmd.exe' list site 'MySite'" > "c:\output.txt" 
2

"CMD/C" で表示されるヘルプ画面は、このメッセージが表示されます。通常どおり/ cの後にすべてを入力しますが、/ cの後ろのすべてを引用符で囲みます。たとえば:

"c:\windows\system32\inetsrv\appcmd.exe" list site "MySite" > "c:\output.txt" 

cmd /c ""c:\windows\system32\inetsrv\appcmd.exe" list site "MySite" > "c:\output.txt"" 
なり
関連する問題