'================================================================== ' ファイルのバージョンチェック・テキストへ書き出し 'http://www10.plala.or.jp/palm84/wsh.html 'http://www10.plala.or.jp/palm84/archives/wsh/FileVersion.vbs.txt 'https://eu7w9wsmf6a74xyjdfzl3q-on.drv.tw/archives/wsh/FileVersion.vbs.txt '================================================================== Option Explicit If WScript.Arguments.Count = 0 Then MsgBox "ファイルが選択されてませんクマー (´・ω・`)",48 ,"クマー? (´;ω;`)" WScript.Quit End If ' FileSystemObject オブジェクト作成 Dim objFSO, objShell Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") ' Shell オブジェクト作成 Set objShell = WScript.CreateObject("WScript.Shell") ' 環境変数の値を取得 'Dim TEMP 'TEMP = objShell.ExpandEnvironmentStrings("%temp%") ' ログファイル Dim appPath, LogFile appPath = objFSO.GetParentFolderName(WScript.ScriptFullName) LogFile = appPath & "\FileVersion_log1.txt" Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim objTxt 'Set objTxt = objFSO.OpenTextFile(LogFile, ForWriting, true, -2) Set objTxt = objFSO.OpenTextFile(LogFile, ForWriting, true, -1) MyFileVer objTxt.Close objShell.Run """" & LogFile & """" Set objTxt = Nothing Set objFSO = Nothing Set objShell = Nothing '********************************************************* 'Sub MyFileVer '********************************************************* Sub MyFileVer Dim objFile, objFolder, objFolderItems, objItem Dim strPath, strFileName, strFolder, strName, strName2, strName3, strName4, strName5 ' Shell.Application オブジェクト作成 Dim objShellApp Set objShellApp = CreateObject ("Shell.Application") For Each strPath In WScript.Arguments If objFSO.FileExists(strPath) Then Set objFile = objFSO.GetFile(strPath) strFileName = objFSO.GetFileName(strPath) strFolder = objFile.ParentFolder Set objFolder = objShellApp.Namespace (strFolder) Set objFolderItems = objFolder.Items Set objItem = objFolderItems.Item(strFileName) objTxt.WriteLine "=========================================================" objTxt.WriteLine strPath objTxt.WriteLine "=========================================================" On Error Resume Next Dim n For n=0 to 400 strName = objFolder.GetDetailsOf(Nothing, n) If strName = "ファイル バージョン" Then objTxt.WriteLine "File Version : " & objFolder.GetDetailsOf(objItem, n) End If Next Dim m For m=0 to 400 strName2 = objFolder.GetDetailsOf(Nothing, m) If strName2 = "製品バージョン" Then objTxt.WriteLine "Product Version : " & objFolder.GetDetailsOf(objItem, m) End If Next Dim l For l=0 to 400 strName3 = objFolder.GetDetailsOf(Nothing, l) If strName3 = "説明" Then objTxt.WriteLine "説明 : " & objFolder.GetDetailsOf(objItem, l) End If Next Dim k For k=0 to 400 strName4 = objFolder.GetDetailsOf(Nothing, k) If strName4 = "ファイルの説明" Then objTxt.WriteLine "ファイルの説明 : " & objFolder.GetDetailsOf(objItem, k) End If Next On Error GoTo 0 objTxt.WriteLine "最終更新日時 : " & objFolder.GetDetailsOf(objItem, 3) objTxt.WriteLine "作成日時 : " & objFolder.GetDetailsOf(objItem, 4) objTxt.WriteLine "サイズ : " & objFolder.GetDetailsOf(objItem, 1) End If Next objTxt.WriteLine "=========================================================" Set objShellApp = Nothing End Sub