WMI using native

Joined
May 4, 2009
Messages
1
Reaction score
0
I am trying to find the Reboot time (LastBootUpTime) of the machine, I was using a simple VB Script file to get it but I found one of the customers has disabled VB script



Using following method due to security restriction

http://www.windowsecurity.com/whitepapers/Windows_Scripting_Host.html



following is the VB script I use cscript to get the reboot time.



strComputer = "."



Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _

("Select * from Win32_OperatingSystem")



For Each objOS in colOperatingSystems

dtmBootup = objOS.LastBootUpTime

dtmLastBootupTime = WMIDateStringToDate(dtmBootup)

Wscript.Echo "System Booted at : " & dtmLastBootupTime

Next



Function WMIDateStringToDate(dtmBootup)

WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _

Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _

& " " & Mid (dtmBootup, 9, 2) & ":" & _

Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))

End Function



I read there is way to make a WMI call using C++ but I am not that good in native code



Can someone point me to the native code in which I can get the reboot time using a WMI call.



Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top