FOR
スクリプトのコマンドに含まれる場合、この WMIC コマンドはどのように記述すればよいですか?
wmic service where (name="themes" and state="running") get
以下のコードは機能しません。
For /F %%a in (
'wmic service where ^("name='themes'" and "state='running'"^) get'
) do (
echo %%a
)
FOR
スクリプトのコマンドに含まれる場合、この WMIC コマンドはどのように記述すればよいですか?
wmic service where (name="themes" and state="running") get
以下のコードは機能しません。
For /F %%a in (
'wmic service where ^("name='themes'" and "state='running'"^) get'
) do (
echo %%a
)
完全な wmic コマンドを一重引用符と二重引用符で囲むことができます。その後、何もエスケープする必要はありません。
FOR /F "delims=" %%a in ('"wmic service where (name="themes" and state="running") get"') do (
echo %%a
)
@echo off
For /F "usebackq delims=" %%a in (`wmic service where 'name^="themes" and state^="running"' get`) do (
echo %%a
)
これは私にとってはうまくいきます.usebackq
オプションを使用して、括弧の代わりに'
代替のwmic構文に問題がないようにしました。'