get files version by vbs

获取某目录下所有dll/exe的文件版本信息

Function IsPEFile(fn)
    IsPEFile = (Right(fn, 4) = ".dll" or Right(fn, 4) = ".exe")
End Function

Dim g_txtFile

Function walkDir(folderspec)
    Dim fso, f, f1, sf
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder(folderspec)
    Set sf = f.Files
    For Each f1 in sf
        fn = folderspec + "/" + f1.name
        if IsPeFile(fn) Then
            fv = fso.GetFileVersion(fn)
            if Len(fv) > 0 Then
                str1 = fn + vbTab + fv
            else
                str1 = fn + vbTab + "no version info"
            End if
            g_txtFile.WriteLine(str1)
        End if
    Next
    
    Set sf = f.SubFolders
    For Each f1 in sf
        fn = folderspec + "/" + f1.name
        walkDir(fn)
    Next
    
End Function

g_dstFile = "versionInfo.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set g_txtFile = fso.CreateTextFile(g_dstFile, True)

walkDir(".")
g_txtFile.Close()
MsgBox("Done")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad " & g_dstFile



 

posted on 2013-01-11 18:06  FlowingCloud  阅读(161)  评论(0编辑  收藏  举报

导航