Copying a file hash to clipboard without PowerShell … isn't easy.

@echo off&amp;(for /f "tokens=*" %%a in ('certutil -hashfile "%1" MD5') do echo %%a&amp;for /f "delims=" %%b in ('echo %%a^|findstr /r /i /x [0-9A-F]*') do if "%%b" neq "" echo %%b|clip&amp;pause&amp;exit)&amp;pause


PowerShell is slow to load so I used batch instead. I use this command to extend the context menu of windows explorer, hence a single line.

There is one minor issue; certutil doesn't support empty files.

Bonus registry entries: https://paste.ee/p/sgSJY
All zero-sized files will have the same checksum using the same given hash algorithm. Hence, use the following batch-script:

@ECHO OFF
SETLOCAL EnableExtensions
for /f %%G in ("%~1") do set "_len=%%~zG"
if %_len% EQU 0 (
  echo MD5 hash of %1
  echo D41D8CD98F00B204E9800998ECF8427E
  echo CertUtil bypassed for zero file size
  echo D41D8CD98F00B204E9800998ECF8427E|clip  
) else (
  for /f "tokens=*" %%a in ('certutil -hashfile "%~1" MD5') do (
    echo %%a
    for /f "delims=" %%b in ('echo %%a^|findstr /r /i /x ^[0-9A-F]*[0-9A-F]$') do (
      if "%%b" neq "" echo %%b|clip
    )
  )
)
pause


Note that %%~zG expands %%G to size of file (read call /?).

if "%%b" neq "" echo %%b|clip seems to be superfluous then. Simple echo %%b|clip should suffice.

Sample output:

==&gt; D:\bat\CodeReview\179105.bat out.txt
MD5 hash of out.txt
D41D8CD98F00B204E9800998ECF8427E
CertUtil bypassed for zero file size
Press any key to continue . . .

==&gt; D:\bat\CodeReview\179105.bat D:\bat\CodeReview\179105.bat
MD5 hash of D:\bat\CodeReview\179105.bat:
c2a4cabffac79a26ee5ed7c97cefb44b
CertUtil: -hashfile command completed successfully.
Press any key to continue . . .

==&gt;