36807
Oct 19, 2010
5105
4
0
Vbs RegEx gesucht
Hallo,
ich möchte für die weitere Verarbeitung der Daten einen Regulären Audruck unter vbs definieren.
Konkret möchte ich aus der Pfadangabe (z.B. C:\Programme\ordner\programm.exe ) den Pfad C:\Programme\ordner und den Namen der .exe Datei in Separaten Variablen zwischenspeichern. Nur leider finde ich keine passende Möglichkeit das herauszufiltern bzw. bin ich mir nicht mal sicher ob das mit vbs überhaupt realisierbar ist ?
Hintergrund der ganzen Aktion ist, dass ich anhand der laufenden Tasks die Versionsnummer vom Programm herausfinden möchte. Leider gibt es in win32_process keine Klasse mit der ich das bewerkstelligen kann. Also habe ich mir gedacht, dass ich über den win32_process ... ExecutablePath die Shell.Application ... GetDetailsOf auslese. Diese benötigt afaik aber separat den exe Namen und den Pfad.
Hintergrund der ganzen Aktion ist, dass ich anhand der laufenden Tasks die Versionsnummer vom Programm herausfinden möchte. Leider gibt es in win32_process keine Klasse mit der ich das bewerkstelligen kann. Also habe ich mir gedacht, dass ich über den win32_process ... ExecutablePath die Shell.Application ... GetDetailsOf auslese. Diese benötigt afaik aber separat den exe Namen und den Pfad.
strComputer = "."
Set dienst = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")'
Set abfrage = dienst.ExecQuery("Select * from Win32_Process")
' print usable information into XML-like format
For Each prozess In abfrage
eigenschaften = prozess.GetOwner(strNameOfUser, strUserDomain)
WScript.Echo "<SOFTWARES>"
WScript.Echo "<PUBLISHER>"& prozess.Name &"</PUBLISHER>"
WScript.Echo "<NAME>"& prozess.caption &"</NAME>"
WScript.Echo "<VERSION>N/A</VERSION>"
WScript.Echo "<FOLDER>" & prozess.ExecutablePath &"</FOLDER>"
WScript.Echo "<COMMENTS>" & "# " & prozess.CommandLine &" #" &"</COMMENTS>"
WScript.Echo "<FILENAME>N/A</FILENAME>"
WScript.Echo "<FILESIZE>N/A</FILESIZE>"
WScript.Echo "<SOURCE>N/A</SOURCE>"
WScript.Echo "<GUID>N/A</GUID>"
WScript.Echo "<LANGUAGE>N/A</LANGUAGE>"
WScript.Echo "</SOFTWARES>"
Next
Please also mark the comments that contributed to the solution of the article
Content-Key: 153348
Url: https://administrator.de/contentid/153348
Printed on: April 19, 2024 at 20:04 o'clock
4 Comments
Latest comment
Hallo gummistiefel!
Das geht auch per FileSystemObject. Beispiel mit 7zip.Exe
Gruß Dieter
Das geht auch per FileSystemObject. Beispiel mit 7zip.Exe
Const Path = "C:\Program Files (x86)\7-Zip\7z.exe"
Dim Fso, File
Dim FileBaseName, FileExtensionName, FileName, FileFolder
Dim FileVersion, FileCreated, FileSize, FileType
Set Fso = CreateObject("Scripting.FileSystemObject")
Set File = Fso.GetFile(Path)
FileBaseName = Fso.GetBaseName(Path) '= "7z"
FileExtensionName = Fso.GetExtensionName(Path) '= "exe"
FileName = Fso.GetFileName(Path) '= "7z.exe"
FileFolder = Fso.GetParentFolderName(Path) '= "C:\Program Files (x86)\7-Zip"
FileVersion = Fso.GetFileVersion(Path) '= "9.10.0.0"
FileCreated = File.DateCreated '= #22.12.2009 14:17:38#
FileSize = File.Size '= 280064
FileType = File.Type '= "Anwendung"
Gruß Dieter
Hallo gummistiefel!
Lösche die Codezeile mit der Konstanten "Const Path = ...." und dann in etwa so:
Gruß Dieter
Lösche die Codezeile mit der Konstanten "Const Path = ...." und dann in etwa so:
'.....
Set Fso = CreateObject("Scripting.FileSystemObject")
'print usable information into XML-like format
For Each prozess In abfrage
Set File = Fso.GetFile(prozess.ExecutablePath)
'FileBaseName = Fso.GetBaseName(File.Path)
'FileExtensionName = Fso.GetExtensionName(File.Path)
'FileName = File.Name
'FileFolder = File.ParentFolder.Path
'FileVersion = Fso.GetFileVersion(File.Path)
'FileCreated = File.DateCreated
'FileSize = File.Size
'FileType = File.Type
'.....
WScript.Echo "<VERSION>" & Fso.GetFileVersion(File.Path) & "</VERSION>"
WScript.Echo "<FOLDER>" & File.ParentFolder.Path & "</FOLDER>"
WScript.Echo "<COMMENTS>" & "# " & prozess.CommandLine & " #" & "</COMMENTS>"
WScript.Echo "<FILENAME>" & File.Name & "</FILENAME>"
WScript.Echo "<FILESIZE>" & File.Size & "</FILESIZE>"
'.....
Next
Gruß Dieter