简体   繁体   中英

Call windows command from a batch file and get its result

What I'm trying to achieve is to call windows command line COMP from my batch file. And then get it's resulting message whether it has differences or not. Is it possible? I have a separate exe to call in comparing files that outputs its differences. But before I call that exe, first I want to know if there are really differences between the files. 'Cause I just want to generate report for those files that has differences. Unfortunately, that separate exe that I use for comparing does not have the capability to know if there are differences via command prompt. It just always generate the result of the files whether it has differences or not.

Don't use comp , but fc . comp always asks whether you want to compare more files, which would be rather obnoxious in a batch file.

Then you can use

fc file1 file2 >nul && (
    echo Identical
) || (
    echo Different
)

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