M
Microsoft
I need to extract the file version from a file. I'll paste the code below.
The problem is that VB returns a value that looks liks this "5.00.2195.6824"
and windows returns a value that looks like this "5.0.2195.6824".. It stops
the comparisons that I do in the script since its always not a match.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim osname As String = ""
Dim servername As String = "wchsms11"
Dim scope As New ManagementScope("\\" & servername & "\root\cimv2")
Dim objectQuery As New ObjectQuery("select * from Win32_OperatingSystem")
Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
Dim os As ManagementObject
scope.Connect()
For Each os In searcher.Get()
osname = os("caption")
Console.WriteLine(osname)
If osname.IndexOf("2000") > 0 Then
Call windows2000(servername)
End If
Next os
End Sub
Private Sub windows2000(ByVal servername As String)
Dim sfile As FileVersionInfo
Dim versioninfo As Object
Dim version As String
versioninfo = sfile.GetVersionInfo("\\" & servername &
"\c$\winnt\system32\basesrv.dll")
version = versioninfo.fileversion
Console.WriteLine(version)
Console.WriteLine(versioninfo)
If version.IndexOf("2195.6824") < 1 Then
Console.WriteLine("notpatched")
Else
Console.WriteLine("patched")
End If
End Sub
The problem is that VB returns a value that looks liks this "5.00.2195.6824"
and windows returns a value that looks like this "5.0.2195.6824".. It stops
the comparisons that I do in the script since its always not a match.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim osname As String = ""
Dim servername As String = "wchsms11"
Dim scope As New ManagementScope("\\" & servername & "\root\cimv2")
Dim objectQuery As New ObjectQuery("select * from Win32_OperatingSystem")
Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
Dim os As ManagementObject
scope.Connect()
For Each os In searcher.Get()
osname = os("caption")
Console.WriteLine(osname)
If osname.IndexOf("2000") > 0 Then
Call windows2000(servername)
End If
Next os
End Sub
Private Sub windows2000(ByVal servername As String)
Dim sfile As FileVersionInfo
Dim versioninfo As Object
Dim version As String
versioninfo = sfile.GetVersionInfo("\\" & servername &
"\c$\winnt\system32\basesrv.dll")
version = versioninfo.fileversion
Console.WriteLine(version)
Console.WriteLine(versioninfo)
If version.IndexOf("2195.6824") < 1 Then
Console.WriteLine("notpatched")
Else
Console.WriteLine("patched")
End If
End Sub