Maanu
Maanu

Reputation: 5203

Output of FindStr to a variable

I want to keep the output of the following command to a variable.

corflags ICEConnectDT.dll | findstr "PE"

When I tried the following statement, it shows the error "| was unexpected at this time."

for /F "delims=" %%a in ('corflags ICEConnectDT.dll | findstr PE') do  echo %%a

How can I solve the issue?

Upvotes: 0

Views: 4640

Answers (1)

dbenham
dbenham

Reputation: 130819

Escape the pipe

for /F "delims=" %%a in ('corflags ICEConnectDT.dll ^| findstr PE') do echo %%a

Or enclose the entire command string in double quotes (inside the single quotes)

for /F "delims=" %%a in ('"corflags ICEConnectDT.dll | findstr PE"') do echo %%a

Upvotes: 3

Related Questions