注:PDCOMP是本机的一个驱动名,但是没有文件路径复制代码
- @echo off
- for /f "usebackq skip=1 delims=" %%a in (
- `"wmic sysdriver where name="PDCOMP" get pathname"`
- ) do (
- if "%%a" == "" (
- echo y
- ) else (
- echo n
- )
- )
- pause
%%a的值可能包含不可见字符,而%var%的值是10个空格。复制代码
- @echo off
- for /f "usebackq skip=1 delims=" %%a in (
- `"wmic sysdriver where name="PDCOMP" get pathname"`
- ) do (
- if "%%a" == " " echo y
- set var=%%a
- )
- if "%var%"==" " echo y
- pause
C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name') do @echo.%a c:\boot.ini C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name /value') do @echo.%a (空行) Name=c:\boot.ini (空行) (空行) C:\>for /f "skip=1 tokens=2 delims==" %a in ('wmic datafile where "name='c:\\boot.ini'" get name /value') do @echo.%a c:\boot.ini C:\>rem 还有以前讨论过的不可见字符问题: C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name') do @echo.%a- -:\boot.ini C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name') do @echo.%~dpa- c:\- C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name') do @echo.%~fa- -:\boot.ini C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name') do @echo.%a-|find /v "" c:\boot.ini - C:\>for /f "tokens=2 delims==" %a in ('wmic datafile where "name='c:\\boot.ini'" get name /value^|find /i ":"') do @echo %a-|find /v "" c:\boot.ini- C:\>for /f "skip=1 delims=" %a in ('wmic datafile where "name='c:\\boot.ini'" get name') do @call echo.%a- c:\boot.ini - C:\>for /f "tokens=2 delims==" %a in ('wmic datafile where "name='c:\\boot.ini'" get name /value^|find /i ":"') do @call echo %a- c:\boot.ini- |
复制代码
- @echo off
- for /f "usebackq skip=1 delims=" %%a in (
- `"wmic sysdriver where name="PDCOMP" get pathname"`
- ) do (
- call :slz %%a
- )
- pause&exit
- :slz
- echo."%1"
复制代码
- @echo off
- for /f "usebackq skip=1 delims=" %%a in (
- `"wmic sysdriver where name="PDCOMP" get pathname/value"`
- ) do (
- set %%a>nul
- )
- echo "%pathname%"
- pause
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |