我要制作一个批处理文件:
这是我到目前为止写的:
false
这是结果:
@ECHO OFF
set temp=202cb962ac59075b964b07152d234b70
CertUtil -hashfile test123.txt MD5
PAUSE
我坚持在“ newmd5”变量中设置输出md5并将其与温度进行比较。
答案 0 :(得分:1)
因此,您的问题可以简化为“如何将certutil
给出的MD5放入变量?”
这可以通过for /f
循环来完成:
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"
将跳过第一行(MD5 has of ...
),if not defined
注意只考虑第二行(哈希),而忽略第三行(CertUtil: -hashfile command completed successfully.
)
我想您不需要if
命令来比较两个变量。