'================================================================== '「送る」に「MD5 SHA1 SHA256 をメモへ書き出し」のショートカットを作りますYO! 'http://www10.plala.or.jp/palm84/wsh.html 'http://palm84.hatenablog.com/entry/20150909/1441733653 'http://www10.plala.or.jp/palm84/archives/wsh/Create_MD5_SHA1_memo-sendto.vbs.txt 'https://eu7w9wsmf6a74xyjdfzl3q-on.drv.tw/archives/wsh/Create_MD5_SHA1_memo-sendto.vbs.txt '================================================================== '最終更新 2022.09.26 Windows 11 向けアイコン変更 '更新 2020.05.30 SHA256 追記 '更新 2019.08.14 Windows 8 対応? '更新 2018.05.03 'Shell オブジェクトを作成 Set objShell = WScript.CreateObject("WScript.Shell") 'FileSystemObject オブジェクトを作成 Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const Reg_ProductName = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName" Const Reg_ReleaseId = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId" Const Reg_CurrentBuildNumber = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber" Title = "MD5-SHA1-SHA256 メモ" MyKakunin '*** 環境変数とか取得 *** If objShell.RegRead(Reg_CurrentBuildNumber) >= "22000" Then myOS = "Windows 11" Else myOS = objShell.RegRead(Reg_ProductName) End IF If InStr(myOS, "Windows 10") > 0 Then myReleaseId = objShell.RegRead(Reg_ReleaseId) End If SendTo = objShell.SpecialFolders("SendTo") Desktop = objShell.SpecialFolders("Desktop") Documents = objShell.SpecialFolders("MyDocuments") CuDir = objShell.CurrentDirectory '*** ログファイル *** Const LogName = "00_MD5_memo.txt" '* デスクトップに作成 strLogDir = Desktop '* マイ ドキュメントに作成 'strLogDir = Documents '* 対象ファイルの場所に作成 'strLogDir = "" '* 任意の場所に作成 'strLogDir = "ディレクトリパスを記述" '* 私的 'strLogDir = Documents & "\Command_WSH" If strLogDir = "" Then strLogPath = LogName Else strLogPath = strLogDir & "\" & LogName End If '*** ショートカット設定 *** strFile = SendTo & "\MD5_SHA1_memo-sendto.bat" strWorkingDirectory = "" strIcon = "%SystemRoot%\system32\shell32.dll, 310" If myOS = "Windows 11" Then strIcon = "%SystemRoot%\system32\shell32.dll, 310" If InStr(myOS, "Windows 10") > 0 Then strIcon = "%SystemRoot%\system32\shell32.dll, 311" If myReleaseId >= "1703" Then strIcon = "%SystemRoot%\system32\shell32.dll, 312" If InStr(myOS, "Windows 7") > 0 Then strIcon = "%SystemRoot%\system32\shell32.dll, 284" strFolder = SendTo If objFSO.FileExists(strFile) Then objFSO.DeleteFile(strFile) Set objTxt = objFSO.OpenTextFile(strFile, ForWriting, true, -2) With objTxt .WriteLine "@echo off" .WriteLine "title %~nx0" .WriteLine "REM ********************************************************************" .WriteLine "REM * 右クリック【送る】から MD5 SHA1 をメモへ書き出し" .WriteLine "REM http://www10.plala.or.jp/palm84/commandline.html" .WriteLine "REM http://palm84.hatenablog.com/entry/20150909/1441733653" .WriteLine "REM ********************************************************************" .WriteLine "if ""%~1""=="""" GOTO NO_PARAM" .WriteLine "for %%x in (""%~a1"") do set check_dir=%%~x" .WriteLine "if /i ""%check_dir:~0,1%""==""d"" GOTO FILECYAU" .WriteLine "" .WriteLine "pushd %~dp0" .WriteLine "for /f ""delims="" %%I in (""certutil.exe"") do set exe_certutil=%%~$PATH:I" .WriteLine "if not defined exe_certutil GOTO NOFILE" .WriteLine "" .WriteLine "pushd %~dp1" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### log" .WriteLine "REM #####################################" .WriteLine "REM ## ログファイル" .WriteLine "set ""log=" & strLogPath & """" .WriteLine "REM ## 任意の場所に作成" .WriteLine "REM set ""log=D:\My_Files\Documents\Command_WSH\00_MD5_memo.txt""" .WriteLine "REM ## 対象ファイルの場所にログ作成" .WriteLine "REM set log=00_MD5_memo.txt" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### CHECK" .WriteLine "REM #####################################" .WriteLine ":CHECK" .WriteLine "if ""%~1""=="""" GOTO SHOW_LOG" .WriteLine "set ""FullPath=%~f1""" .WriteLine "call :SUB" .WriteLine "" .WriteLine "shift" .WriteLine "GOTO CHECK" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### SUB" .WriteLine "REM #####################################" .WriteLine ":SUB" .WriteLine "for /f ""usebackq delims="" %%a in (`certutil -hashfile ""%FullPath%"" MD5 ^| findstr /v "":""`) do (" .WriteLine "set ""value=%%a""" .WriteLine ")" .WriteLine "set ""value=%value: =%""" .WriteLine "REM set ""value=%value:~1%""" .WriteLine ">>""%log%"" echo %FullPath%" .WriteLine ">>""%log%"" echo MD5 : %value%" .WriteLine "" .WriteLine "for /f ""usebackq delims="" %%a in (`certutil -hashfile ""%FullPath%"" SHA1 ^| findstr /v "":""`) do (" .WriteLine "set ""value=%%a""" .WriteLine ")" .WriteLine "set ""value=%value: =%""" .WriteLine "REM set ""value=%value:~1%""" .WriteLine ">>""%log%"" echo SHA1 : %value%" .WriteLine "" .WriteLine "for /f ""usebackq delims="" %%a in (`certutil -hashfile ""%FullPath%"" SHA256 ^| findstr /v "":""`) do (" .WriteLine "set ""value=%%a""" .WriteLine ")" .WriteLine "set ""value=%value: =%""" .WriteLine "REM set ""value=%value:~1%""" .WriteLine ">>""%log%"" echo SHA256: %value%" .WriteLine ">>""%log%"" echo:" .WriteLine "" .WriteLine "exit /b" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### SHOW_LOG" .WriteLine "REM #####################################" .WriteLine ":SHOW_LOG" .WriteLine "start """" ""%log%""" .WriteLine "GOTO :EOF" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### NO_PARAM" .WriteLine "REM #####################################" .WriteLine ":NO_PARAM" .WriteLine "echo:" .WriteLine "echo ==============================================================" .WriteLine "echo !引数(ファイル指定)がないですYO!" .WriteLine "echo ==============================================================" .WriteLine "echo:" .WriteLine "GOTO END" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### NOFILE" .WriteLine "REM #####################################" .WriteLine ":NOFILE" .WriteLine "echo:" .WriteLine "echo ==============================================================" .WriteLine "echo !certutil.exe がありませぬ...." .WriteLine "echo ==============================================================" .WriteLine "echo:" .WriteLine "GOTO END" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### FILECYAU" .WriteLine "REM #####################################" .WriteLine ":FILECYAU" .WriteLine "echo:" .WriteLine "echo ==============================================================" .WriteLine "echo ! %~1 " .WriteLine "echo:" .WriteLine "echo ! ... はディレクトリどすえ" .WriteLine "echo ==============================================================" .WriteLine "echo:" .WriteLine "GOTO END" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### END" .WriteLine "REM #####################################" .WriteLine ":END" .WriteLine "echo:" .WriteLine "echo *** 何かキーを押すと閉じます *** " .WriteLine "pause >nul" .Close End With Set objFile = objFSO.GetFile(strFile) objFile.Attributes = objFile.Attributes + 2 MySC OldTitle = "MD5-SHA1 メモ" MyDeleteFile MsgBox "「送る」に「" & Title & "」のショートカットを作成しました YO!",64 ,"(´・ω・`) クマー! " Set objTxt = Nothing Set objShortCut = Nothing Set objFile = Nothing Set objFSO = Nothing Set objShortcut = Nothing Set objShell = Nothing '********************************************************* 'Sub MyKakunin '********************************************************* Sub MyKakunin Kakunin = MsgBox ("「送る」 に 「" & Title & "」 のショートカットを作りますのん?" & vbCrLf & " (´・ω・`)", 65 ,"「送る」 に 「" & Title & "」 のショートカットを作るYO! (´・ω・`) ") If Kakunin = 2 Then WScript.Quit End If End Sub '********************************************************* 'Sub MySC '********************************************************* Sub MySC strShortCut = SendTo & "\" & Title & ".lnk" '*** ショートカットオブジェクトを作成 *** Set objShortCut = objShell.CreateShortcut(strShortCut) With objShortCut ' リンク先 .TargetPath = strFile ' 作業フォルダ .WorkingDirectory = strWorkingDirectory ' 引数 .Arguments = "" ' コメント .Description = "" ' アイコン .IconLocation = strIcon End With objShortCut.Save ' ショートカットを DeskTop へコピー ' objFSO.CopyFile strShortCut, DeskTop & "\" 'WScript.Echo strFileName & "にショートカットを作成しました。" End Sub '********************************************************* 'Sub MyDeleteFile '********************************************************* Sub MyDeleteFile strShortCut = Sendto & "\" & OldTitle & ".lnk" 'ファイルが存在するなら削除 If objFSO.FileExists(strShortCut) Then objFSO.DeleteFile(strShortCut) End If End Sub