Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '==============================================================================
- '
- ' NAME: getExeInfo.vbs
- '
- ' SITE : HTTP://ITTECHLOG.WORDPRESS.COM
- '
- ' COMMENT: This script lists all exe files from a given path, incl FileVersion
- ' It also checks if a found exe-file is installed as a Service.
- '==============================================================================
- Option Explicit
- On Error Resume Next
- Dim strDir, strScriptPath, strTextFile
- Dim qryServices
- Dim objFSO, objDir, objWMIService, objService
- strDir = "Q:\"
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objDir = objFSO.GetFolder(strDir)
- Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
- Set qryServices = objWMIService.ExecQuery ("Select * from Win32_Service")
- strScriptPath = objFSO.GetParentFolderName(wscript.ScriptFullName)
- Set strTextFile = objFSO.CreateTextFile(strScriptPath & "\FileInfo.txt", True)
- FindFiles(objDir)
- strTextFile.Close
- Wscript.echo "Done"
- Sub FindFiles(strCurrentDir)
- Dim strFile, strService
- For Each strFile In strCurrentDir.Files
- If LCase(Right(Cstr(strFile.Name), 4)) = ".exe" Then
- 'check if exe is listed as service
- For Each objService in qryServices
- If (InStr(objService.PathName,strFile.Name)) Then
- strService = objService.DisplayName & " (" & objService.PathName & ")"
- Else
- strService = ""
- End If
- Next
- 'list exe with FileVersion and Service
- strTextFile.WriteLine(strFile.Name & vbTab & vbTab & vbTab & objFSO.GetFileVersion(strCurrentDir & "\" & strFile.Name)) & vbTab & strService
- End If
- Next
- For Each strFile In strCurrentDir.SubFolders
- FindFiles(strFile)
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement