MD5 Create and Remote Check

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DUTCHED
Posts: 2
Joined: 24 Dec 2010 05:13

MD5 Create and Remote Check

#1 Post by DUTCHED » 24 Dec 2010 05:17

Hey,


Due the many files and exe's, that I deploy from my system. Sometimes it happens that some exe or file gets corrupted.

Therefor I want to add a script to my release scripts. That generates MD5's from files and exe's that is gathered from my pc. And when it is uploaded to the remote pc's it checks the MD5's.

Is this possible? If so, what do I need to use for that.

thnx

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: MD5 Create and Remote Check

#2 Post by !k » 24 Dec 2010 08:37

See copying & verifing checksums http://forum.wincmd.ru/viewtopic.php?p=58069
Options: names.list "d:\destination\"
Names.list format is

Code: Select all

file.ext
file too.ext
file 3.ext
folder\
folder too\
folder 3\

DUTCHED
Posts: 2
Joined: 24 Dec 2010 05:13

Re: MD5 Create and Remote Check

#3 Post by DUTCHED » 24 Dec 2010 08:44

thanks mate, wil look into tonight, since the website u gave is blocked by my current firewall :-)

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: MD5 Create and Remote Check

#4 Post by !k » 24 Dec 2010 10:26

Code: Select all

@echo off
rem Copying & verifing checksums
rem Options: names.list "d:\destination\"
rem Uses: RHash http://rhash.anz.ru/
setlocal enableextensions
for /f "delims=" %%n in (%1) do (
call :x "%%n" "%~2"
)
move ~hashs~.tmp "%~2~hashs~.tmp"
chdir /d "%~2"
for /f "usebackq delims=" %%h in ("%~2~hashs~.tmp") do (
title Check %%h
rhash.exe -c --ansi %%h 2>nul |findstr /r /c:"ERROR, .* should be" >>~err~.txt
)
for %%e in (~err~.txt) do (if "%%~ze"=="0" del "%%~nxe" /q)
if exist ~err~.txt start ~err~.txt
del "%~2~hashs~.tmp" /q
exit /b
:x
set "l=%~1"
title Hashing "%l%"
if "%l:~-1%"=="\" (
rhash.exe -r -M --ansi "%l:~0,-1%" >>"%l:~0,-1%.md5" 2>nul
title Copying "%l%"
xcopy "%l%*" "%~2%l%" /i /s/e /k/r/h >nul
type "%l:~0,-1%.md5" >>"%~2%l:~0,-1%.md5"
echo "%l:~0,-1%.md5" >>~hashs~.tmp
) else (
rhash.exe -M --ansi "%l%" >>"%l%.md5" 2>nul
title Copying "%l%"
echo f| xcopy "%l%" "%~2%l%" /k/r/h >nul
type "%l%.md5" >>"%~2%l%.md5"
echo "%l%.md5" >>~hashs~.tmp
)
goto :eof

Post Reply