Monday, December 1, 2008

Win32_OperatingSystem-find computer last bootup time

Hi Firends yesterday i have play with Win32_Operating System class and i have found out using this task i can intract with my computer operating system.. I had dig into that and for sample here i am going to write code to find out your computer last bootup time
VB.NET Code

Public Sub Lastbootuptime()
Dim strComputer As String = "." ' Local computer
Dim objWMIDateTime As Object = CreateObject("WbemScripting.SWbemDateTime")
Dim objWMI As Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colOS As Object = objWMI.InstancesOf("Win32_OperatingSystem")
For Each objOS In colOS
objWMIDateTime.Value = objOS.LastBootUpTime
MessageBox.Show("Last Boot Up Time: " & objWMIDateTime.GetVarDate)
Next
End Sub

Abhishek Hingu at:
http://www.indianic.com/

1 comment: