dim strComputer as string = machinenametextbox.text Dim MyObjSearcher As System.Management.ManagementObjectSearcher Dim MyColl As System.Management.ManagementObjectCollection Dim MyObj As System.Management.ManagementObject Dim MyConOptions As New System.Management.ConnectionOptions With MyConOptions .Impersonation = System.Management.ImpersonationLevel.Impersonate .Authentication = System.Management.AuthenticationLevel.Packet End With Dim MyMgtScope As System.Management.ManagementScope MyMgtScope = New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", MyConOptions) MyMgtScope.Connect() If MyMgtScope.IsConnected = False Then Exit Sub End If '---------------------------------------------------------------------------- 'Basic machine INnformation for the left column '---------------------------------------------------------------------------- Try MyObjSearcher = New System.Management.ManagementObjectSearcher(MyMgtScope.Path.ToString, _ "Select * FROM Win32_OperatingSystem") MyColl = MyObjSearcher.Get For Each MyObj In MyColl OSNAME = (MyObj("caption").ToString()) If OSNAME = "Microsoft Windows 7 Enterprise " Then OSNAME = "Windows 7" RadLabel1.Text = "CAE Info" ElseIf OSNAME = "Microsoft Windows XP Professional" Then OSNAME = "Windows XP" RadLabel1.Text = "Radia Info" CAE_Tab.Item.Visibility = ElementVisibility.Collapsed End If BackgroundWorkerMachineInfo.ReportProgress(10) Next Catch ex As Exception OSNAME = "UnKnown" End Try Try MyObjSearcher = New System.Management.ManagementObjectSearcher(MyMgtScope.Path.ToString, _ "Select * FROM Win32_OperatingSystem") MyColl = MyObjSearcher.Get For Each MyObj In MyColl SERVICEPACK = (MyObj("servicepackmajorversion").ToString()) IMAGEDATE = ManagementDateTimeConverter.ToDateTime(CStr(MyObj("InstallDate"))) LASTREBOOT = ManagementDateTimeConverter.ToDateTime(CStr(MyObj("LastBootUpTime"))) BackgroundWorkerMachineInfo.ReportProgress(20) Next Catch ex As Exception SERVICEPACK = "Unavailable" IMAGEDATE = "Unavailable" LASTREBOOT = "Unavailable" End Try
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)