Reputation: 31
I want to make a batch file that:
This is what I wrote so far:
@ECHO OFF
set temp=202cb962ac59075b964b07152d234b70
CertUtil -hashfile test123.txt MD5
PAUSE
This is the result:
MD5 hash of test123.txt:
202cb962ac59075b964b07152d234b70
CertUtil: -hashfile command completed successfully.
Press any key to continue..
I'm stuck with set the output md5 in “newmd5” variable and compare it to temp.
Upvotes: 1
Views: 590
Reputation: 56228
So your question can be reduced to "how to put the MD5 given by certutil
to a variable?"
That can be done by a for /f
loop:
set "test="
for /f "skip=1 delims=" %%a in ('certutil -hashfile test123.txt MD5') do if not defined test set "test=%%a"
set "test=%test: =%"
"skip=1"
will skip the first line (MD5 has of ...
), if not defined
takes care that only the second line (the hash) is considered, ignoring the third line (CertUtil: -hashfile command completed successfully.
)
I guess you don't need help with the if
command to compare the two variables.
Upvotes: 1