문제

디렉토리에서 DLL을 재귀 적으로 스캔하고 모든 버전 번호에 대한 보고서를 생성 할 수있는 스크립트를 작성하고 싶습니다.

스크립트를 사용하여 DLL의 버전 번호를 어떻게 감지 할 수 있습니까? 더 나은 방법이 없다면 VBScript 솔루션이 선호됩니다.

도움이 되었습니까?

해결책

당신은 사용할 수 있습니다 FileSystemObject 개체 파일 시스템에 액세스 할 수 있습니다 GetFileVersion 방법 파일 버전 정보를 얻는 방법.

VBScript 예제를 요청했습니다. 여기에 다음과 같습니다.

Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
PrintDLLVersions oFSO.GetFolder(WScript.Arguments.Item(0))

Sub PrintDLLVersions(Folder)
  Dim oFile, oSubFolder

  ' Scan the DLLs in the Folder
  For Each oFile In Folder.Files
    If UCase(oFSO.GetExtensionName(oFile)) = "DLL" Then
      WScript.Echo oFile.Path & vbTab & oFSO.GetFileVersion(oFile)
    End If
  Next

  ' Scan the Folder's subfolders
  For Each oSubFolder In Folder.SubFolders
    PrintDLLVersions oSubFolder
  Next
End Sub

용법:

> cscript //nologo script-file.vbs 폴더 > 파일 아웃

예 :

> cscript //nologo dll-list.vbs C:\Dir > dll-list.txt

샘플 출력 :

C:\Dir\foo.dll 1.0.0.1
C:\Dir\bar.dll  1.1.0.0
C:\Dir\SubDir\foobar.dll    4.2.0.0
...

다른 팁

편집하다 제 생각에는 이것 내가 참조 한 소스입니다

이것은 내가 사용하는 대본이지만 사과하지만 어디에서 기억하지 못합니다. (따라서 독자, 이것이 스크립트로 시작되면 앞으로 나아갈 수 있습니다.

@echo off
setlocal
set vbs="%temp%\filever.vbs"
set file=%1

echo Set oFSO = CreateObject("Scripting.FileSystemObject") >%vbs%
echo WScript.Echo oFSO.GetFileVersion(WScript.Arguments.Item(0)) >>%vbs%

for /f "tokens=*" %%a in (
'cscript.exe //Nologo %vbs% %file%') do set filever=%%a

del %vbs%
echo Full file version of %file% is: %filever%

for /f "tokens=2 delims=. " %%a in ("%filever%") do set secondparam=%%a
set splevel=%secondparam:~0,1%
echo SP level is: %splevel%

endlocal
pause
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top