cantoris
asked on
Batch (CMD) file issue within expanded IF construct
Hi,
I have the following method of checking a file version working:
I tried redirecting the output of the filever.exe (without the pipe) to a text file and it was as expected.
I then tried redirecting the output of the find.exe to a text file and there was no output.
It's as though the piping to the FIND command no longer works inside the IF construct. Any idea why? Thanks!
I have the following method of checking a file version working:
filever.exe /B /A /D "C:\Program Files\Folder\File.exe" | find "1.1.1.1" >nul
If '%errorlevel%'=='0' Goto DoSomething
But it doesn't work if I do it inside an expanded IF block like this:if exist "C:\Program Files\Folder\File.exe" (
filever.exe /B /A /D "C:\Program Files\Folder\File.exe" | find "1.1.1.1" >nul
if '%errorlevel%'=='0' (
rem Something here
) else (
rem Something here
)
) else (
rem Something here
)
It no longer does the version match correctly. The %errorlevel% is always 0. I tried redirecting the output of the filever.exe (without the pipe) to a text file and it was as expected.
I then tried redirecting the output of the find.exe to a text file and there was no output.
It's as though the piping to the FIND command no longer works inside the IF construct. Any idea why? Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER