Announcement

Collapse
No announcement yet.

Looking for PC-Uptime (not hs.systemuptime)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Looking for PC-Uptime (not hs.systemuptime)

    I would like to display system uptime (when PC was started) not the time HS was up.
    How can I get this using vbs ??

    -b

    #2
    I have a command running during my computer's startup (I do it from the Windows Startup group, but you could use autoexec.bat if you would rather see the minute the PC starts rather than when Windows is running) which modifies a file called C:\Lastboot.txt. The command is simple: date >c:\lastboot.txt

    Then I simply look at the file's last modification date using the functions in my File Properties include. That's the date of the last system boot.

    I can use my standard Since string generation include script to convert that datestamp into a string like "Yesterday at 7:11am" or "Saturday at 9:53pm" or "2002-10-11 at 12:15pm".

    Nucleus Home Automation | System Specs
    News, support, and updates for Rover, Network Monitor, TimeIcons, and more

    Comment


      #3
      whew, several ways of doing this

      on XP you could capture this output:
      <pre class="ip-ubbcode-code-pre">systeminfo | findstr "Up.Time"</pre>

      on Win2k, you could install uptime.exe from the support tools on the win2k CD

      You could also download uptime.exe from sysinternals which will run on any OS of your choice (sysinternals.com)

      and I found this piece of script in my vbs library, ran fine on XP , didn't test it on any other machines.
      <pre class="ip-ubbcode-code-pre">
      Dim objFileSystem
      Dim objOutputFile
      Dim objService
      Dim objOSSet
      Dim objOS
      Dim strWBEMClass

      strWBEMClass = "Win32_OperatingSystem"

      Set objLocator = CreateObject("WbemScripting.SWbemLocator")
      Set objService = objLocator.ConnectServer (strServer, strNameSpace,strUserName, strPassword)

      ObjService.Security_.impersonationlevel = 3

      Set objOSSet = objService.InstancesOf(strWBEMClass)

      For Each objOS in objOSSet

      MsgBox("Last Bootup = " & formatTime(objOS.LastBootUpTime))

      Next


      Private Function formatTime(strDate)
      Dim str
      str = Mid(strDate,1,4) & "-" _
      & Mid(strDate,5,2) & "-" _
      & Mid(strDate,7,2) & ", " _
      & Mid(strDate,9,2) & ":" _
      & Mid(strDate,11,2) & ":" _
      & Mid(strDate,13,2)
      formatTime = str
      End Function


      </pre>

      Let me know if any of this worked. Good luck
      HSPRO 2.4 (ESXi 4.1) | my.Alert NEW | my.Trigger | HSTouch | ACRF2 | UltraM1G | BLWeather | BLLan | Rover
      (aka xplosiv)
      Do You Cocoon? Home Automation News, Tutorials, Reviews, Forums & Chat

      Comment

      Working...
      X