简体   繁体   中英

Using pipe command in a batch file

I'm trying to write a batch file that searches through devices using devcon and then runs "devcon enable" on these devices.

My batch file looks like this:

for /f "tokens=1 delims=:" %%i in ('devcon find *VENDER_INFO* ^| findstr /C:"DEVICEINFO"') do devcon enable "@"%%i

You can ignore the " VENDER_INFO " and "DEVICEINFO" as I simply redacted these to make the commands easier to read.

When I run this.bat file, It appears as though the

devcon find *VENDER_INFO* ^| findstr /C:"DEVICEINFO"

command is only running the first part and failing to pipe the results through

findstr /C:"DEVICEINFO"

Can you see anything wrong with my .bat file? Why is it ignoring the pipe and second part of the find command? I tried removing the "^" but this fails and says "|" was unexpected.

The find command requires double quotes.

Read the help with this:

find /?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM