lundi 19 mars 2018

Using indstr in if in batch-file

I tried last week to figure out how an if works in a batch file and no that it should work it just doesn't. I have no idea what's wrong or how to solve the problem since I may have made an error with the if or that I'm missing out on something important.

findstr /C:"Firefox" C:\TestIffile.txt
pause
IF (findstr /C:"Firefox" C:\TestIffile.txt) (
ECHO Firefox > C:\TestIffileResult.txt
) ELSE (
ECHO no Firfox
)

The first findstr works fine and gives me this result. DisplayName REG_SZ Mozilla Firefox 58.0.2 (x64 en-GB) which is perfectly fine. The second findstr gives me something like "Firefox was unintended". I've been told that the if would handle the findstr command with a true or false signal but if so why won't it work properly? Thank you in advance.

Btw it's not to find the exe of the program but to save a lot of work by filtering out unwanted lines in my datafiles.

Aucun commentaire:

Enregistrer un commentaire