LoginSignup
1

More than 5 years have passed since last update.

バッチファイルだけで、指定フォルダーにあるファイル全部のチェックサムリストを作ろう

Posted at

これを利用して、指定フォルダーの特定拡張子のファイル全部に対して、チェックサムのリストを作るバッチファイルを書いてみた(サンプルは %windir% だけにしているが、複数フォルダーも指定可能)

このバッチで客先環境とテスト環境で想定外の差異が発生していないかチェックできるぜ。

checksum1.cmd
@echo off
for %%I in (
    "%windir%"
) do pushd %%I & call :sum & popd
exit /b

:sum
    echo.
    echo ******************** %CD% *************************
    echo.
    for %%I in (
        *.dll
        *.exe
    ) do for /F "skip=1 tokens=*" %%J in (
        'certutil -hashfile "%%I" ^| findstr /v [C]ertUtil'
    ) do echo %%J %%I
    exit /b

Windows10 の場合:


******************** C:\Windows *************************

e75781e15270a4913ec7d749346a27df4ea6d9d6 twain_32.dll
e8edea2110d9c5f3d9ed931cdb535e92be25536d bfsvc.exe
b508012a71504be378757825d558f48da4d11d64 explorer.exe
b852f6e3876fc32b25b9bc9484006ca30e298b2d HelpPane.exe
2925f8db589a5752984d84ad334e6ed57f3c3ab4 hh.exe
2302ba58181f3c4e1e44a47a7d214ee9397cf2ba notepad.exe
00899dd7411ae8490f5995067370ef1e8019e52d regedit.exe
71d08d00ba575bd156c3f54bc78557fe6caf1083 splwow64.exe
c81f1a6683e0c145088d4b3929eafd636210c7e2 winhlp32.exe
c2bf322de4c9a56145c6947704a77c595a7f80e9 write.exe

Windows7 の場合:


******************** C:\Windows *************************

3c ac d2 04 8d b8 8f 4f 2e 86 3b 6d e3 b1 fd 19 79 22 b3 f2 twain.dll
d8 5b 3d 28 00 ef 51 9b 53 22 b9 3c 1e a8 c0 a8 09 2c 39 ec twain_32.dll
90 f6 70 e6 9a 3a f3 02 5e 4e 69 dd 77 53 d8 85 63 8c 83 7c bfsvc.exe
16 43 e6 d0 26 5e b6 0b 07 53 cd c9 c2 83 d8 43 b9 88 e1 d5 explorer.exe
a7 cc 86 49 44 69 85 7c 5f c2 99 8e 8d 3d 60 39 04 2a be ce fveupdate.exe
22 b8 10 44 4a 4e de ba f8 74 91 84 c5 ea 54 1f ee bd 8f 02 HelpPane.exe
8a 2c 05 87 3a 05 1a 03 31 49 e0 26 77 90 d2 ac 3d de ff 34 hh.exe
fc 64 b1 ef 19 e7 f3 56 42 b2 a2 ea 5f 5d 9f 42 46 86 62 43 notepad.exe
68 22 14 96 12 28 45 3c 38 98 54 e8 1e 67 86 df 92 bb fa 67 regedit.exe
d0 e8 17 97 31 7b ca 26 76 58 7f f9 d0 1d 74 4b 23 3a d5 ec twunk_16.exe
e2 07 de 5c 58 02 79 ad 40 c8 9b f6 f2 c2 d4 7c 77 ef d6 26 twunk_32.exe
05 df 70 6a 41 18 be 1b ee a9 06 91 ff 4a 29 22 92 44 28 8e winhelp.exe
2e ce 29 e4 ae 3f db 71 3c 18 15 2f 5c 75 56 a1 aa 8a 7c 83 winhlp32.exe
11 35 aa 35 54 ff 08 fb b3 7f 8c a3 5c 58 1b af d6 46 be 53 write.exe

Windows7 と Windows10 で出力が違うみたいですが、どうも CertUtil.exe の出力仕様の差みたいですね。まぁ、これくらいはなんとでもなるはず…きっと

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1