r/BatchScripts • u/Khan-Bilal • Jun 10 '21
Error saying "| was unexpected at this time"
Good Morning,
I am trying to write a windows bat script that captures the output (pid only) of a process and passes it in a variable. So that i can pass the variable in to another command. Below is what i have written but i get the above error in the title.
@echo off
FOR /F %%i in (\tasklist /v /fi "imagename eq avgbrowser.exe" /fi "cputime gt 01:25:00" /FO LIST | find "PID:"`) DO (`
SET var=%%i
)
ECHO %var%Can someone please help me figure out what i did wrong?
3
Upvotes
1
u/elgiad007 Jun 10 '21
I believe you can escape the pipe character by preceding it with ^
1
u/Dr_Legacy Jun 10 '21
lose the backslash before
tasklist0
u/[deleted] Jun 10 '21
[deleted] — view deleted comment