Page 1 of 1

[BAT] Get-FileHash (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512)

Posted: 31 Jul 2018 03:59
by Hackoo
Hi :wink:
This script can get all the Hashes (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512) with Certutil.exe command from a file by drag and drop on this batch script and save the results in a text file.

Code: Select all

@echo off
Color 0A & Mode 136,10
Title GET ( MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512 ) HASHES from file by drag and drop using Certutil by Hackoo 2018
Set ScriptName=%~nx0
if "%~1"=="" goto error
Set LogFile=%~nx1_HASHES.txt
If Exist "%LogFile%" Del "%LogFile%"
echo(
SetLocal EnableDelayedExpansion
for %%a in (MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512) do (
     for /f "skip=1 delims=" %%H in ('CertUtil -hashfile "%~1" %%a ^| findstr /i /v "CertUtil"') do ( set H=%%H)
( echo %%a=!H!)
( echo %%a=!H!)>> "!LogFile!"
)
EndLocal
Timeout /T 1 /NoBreak>nul & Start "" "%LogFile%" & Exit
REM --------------------------------------------------------------------------------------
:Error
Color 0C & Mode 104,5
echo( & echo(
echo               You should drag and drop a file over this batch file "%ScriptName%"
Timeout /T 5 /nobreak>nul & exit
REM --------------------------------------------------------------------------------------
So, in order to improve this batch script, i wonder if is it possible to add a function in the same batch file that can check if this script exists on the right context menu; if yes, we exit the funcion, otherwise we create a right click menu for this batch script ?

Re: [BAT] Get-FileHash (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512)

Posted: 31 Jul 2018 06:43
by dbenham
Not an answer to your question, but you might want to check out HASHSUM.BAT v1.5 - emulate md5sum, shasum, and the like


Dave Benham

Re: [BAT] Get-FileHash (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512)

Posted: 31 Jul 2018 10:08
by aGerman
Hackoo wrote:
31 Jul 2018 03:59
i wonder if is it possible to add a function in the same batch file that can check if this script exists on the right context menu
Depends what context menu item you're talking about. Could be an item in the Send To which means that it is a link in the SenTo folder. Or it's a registry setting (see viewtopic.php?f=3&t=8729). Not sure what exactly you're referring to.

Steffen

Re: [BAT] Get-FileHash (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512)

Posted: 31 Jul 2018 10:14
by Hackoo
aGerman wrote:
31 Jul 2018 10:08
Hackoo wrote:
31 Jul 2018 03:59
i wonder if is it possible to add a function in the same batch file that can check if this script exists on the right context menu
Depends what context menu item you're talking about. Could be an item in the Send To which means that it is a link in the SenTo folder. Or it's a registry setting (see viewtopic.php?f=3&t=8729). Not sure what exactly you're referring to.

Steffen
Thank you for the relpy !
I think registry setting that what i want ;)

Re: [BAT] Get-FileHash (MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512)

Posted: 31 Jul 2018 10:26
by aGerman
Did you have a look at the linked thread? Basically all you can do by executing a .reg file can also be done using the REG command. REG QUERY to check if a certain value exists and REG ADD to add or change a value. Just use CMD /C and the full path of your Batch script and forward %1 to the script.

Steffen