【发布时间】:2017-03-02 17:34:50
【问题描述】:
已经能够将以下确实有效的内容放在一起,但最后有一个额外的行。
For /f "tokens=1,2 skip=1 delims=\" %%i IN (
'WMIC service WHERE "name LIKE 'tomcat%%'" GET PathName'
) DO (
echo %%i\%%j
)
Pause
运行时,我们看到:
- D:\tomcat
- D:\tomcat2
- \
而\是不正确的。
【问题讨论】:
-
我会推荐 PowerShell 而不是批处理(一行):
gwmi Win32_Service -Filter "Name LIKE 'tomcat%'" | % { $_.PathName }
标签: batch-file wmi wmic