certutil-hash.cmd的代码:
@echo off
certutil -hashfile "%~dpnx0" md5
pause>nul
我想将整个第二行与变量中的哈希值一起保存。CMD-输出:
MD5 hash from C:\Users\ZerTerO\Desktop\certutil-hash.cmd:
9913d66d0b741494962e94ff540a8147
CertUtil: -hashfile command executed successfully.
对我来说,唯一的解决方案是这样的:
@echo off
cls
call:hashfile
set "md5=%md5: =%"
echo.%md5%
pause>nul
exit
:hashfile
for /f "skip=1 tokens=1 delims=" %%a in ('certutil -hashfile "%~dpnx0" md5') do (set "md5=%%a" & goto:eof)
有没有更优雅的解决方案?
我只需要这样做,因为 Windows 7 和 Windows 8 在值之间写入空格:
set "md5=%md5: =%"
提前致谢...
ZerTerO