'================================================================== '「送る」から SHA256 (MD5/SHA1) リストファイル作成【一つのファイルに追記】のショートカットを作りますYO! 'http://www10.plala.or.jp/palm84/wsh.html 'http://palm84.hatenablog.com/entry/20150910/1441884571 'http://www10.plala.or.jp/palm84/archives/wsh/Create_MD5_Make_list-sendto.vbs.txt 'https://eu7w9wsmf6a74xyjdfzl3q-on.drv.tw/archives/wsh/Create_MD5_Make_list-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" 'strMD = "MD5" 'strMD = "SHA1" strMD = "SHA256" Title = strMD & " リストファイル作成" MyKakunin '*** 環境変数とか取得 *** SendTo = objShell.SpecialFolders("SendTo") 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 '*** ショートカット設定 *** strFile = SendTo & "\" & strMD & "_Make_list-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" 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/20150910/1441884571" .WriteLine "REM ********************************************************************" .WriteLine "set MD=" & strMD .WriteLine "REM set MD=SHA1" .WriteLine "" .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 "set ""log=00_%MD%_list.txt""" .WriteLine "" .WriteLine "" .WriteLine "REM #####################################" .WriteLine "REM ### MAKEFILE" .WriteLine "REM #####################################" .WriteLine ":MAKEFILE" .WriteLine "if ""%~1""=="""" GOTO SHOW_LOG" .WriteLine "set ""File=%~1""" .WriteLine "set ""FileName=%~nx1""" .WriteLine "for /f ""usebackq delims="" %%x in (`certutil -hashfile ""%File%"" %MD% ^| findstr /v "":""`) do (" .WriteLine "set ""value=%%x""" .WriteLine ")" .WriteLine "set ""value=%value: =%""" .WriteLine ">>%log% echo %value% %FileName%" .WriteLine "shift" .WriteLine "GOTO MAKEFILE" .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 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