Startup / Shutdown time

Hello

I would like to make a program telling me when my computer was started and when it was shutdown for the past 10 days for example.

I am not sure if windows logs the time or is there a way to find the time through another way

What API should I use

Thank you in advance !



Answer this question

Startup / Shutdown time

  • Matt Greenwald

    Hey thanks,

    yes that would be one way but there is another way I think.

    There is a program called "PcOnOffTime" (www.neuber.com) that does not run as a service, and does not log anything... It uses windows but not sure how it works...


  • Cesar Francisco

    Ho Zoroxeus,

    You would that develop a window service to write a log file. Later, you look report's your application.

    Good Coding!

    Javier Luna
    http://guydotnetxmlwebservices.blogspot.com/



  • Barts007

    Great news!

    I will buy it ASAP :)

    Good Coding!

    Javier Luna
    http://guydotnetxmlwebservices.blogspot.com/



  • superjoe30

    most likely API calls, which can be easily achieved, or using the WMI approach.

    Import the System.Management.Instrumentation namespace, and add this code to say a button click event:

     



    Dim theScope as new ManagementScope("\\yourComputerName\root\cimv2")
     
    Dim theQueryString as new System.Text.StringBuilder()
    theQueryString.Append("SELECT * FROM Win32_OperatingSystem")
     
     
    Dim theObjectQuery as new ObjectQuery(theQueryString.ToString())
    Dim theSearcher as new ManagementObjectSearcer(theScope, theObjectQuery)
    Dim theCollectionOfResults as new ManagementObjectCollection = theSearcher.Get()
     
     
    for each theCurrentResult as ManagementObject in theCollectionOfResults
       MessageBox.Show(theCurrentResult("LastBootupTime").ToString())
    next

     



  • Startup / Shutdown time