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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Hackoo
Posts: 63
Joined: 15 Apr 2014 17:59

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

#1 Post by Hackoo » 31 Jul 2018 03:59

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 ?
Last edited by Squashman on 31 Jul 2018 06:15, edited 1 time in total.
Reason: MOD EDIT: removed image.

dbenham
Expert
Posts: 2218
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#2 Post by dbenham » 31 Jul 2018 06:43

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

aGerman
Expert
Posts: 3605
Joined: 22 Jan 2010 18:01
Location: Germany

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

#3 Post by aGerman » 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

Hackoo
Posts: 63
Joined: 15 Apr 2014 17:59

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

#4 Post by Hackoo » 31 Jul 2018 10:14

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 ;)

aGerman
Expert
Posts: 3605
Joined: 22 Jan 2010 18:01
Location: Germany

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

#5 Post by aGerman » 31 Jul 2018 10:26

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

Post Reply