WSHを使用して、OSの起動時間と起動してからの経過時間を表示する例です。
WMIで各値を取得するのですが、UTCで値が返ってきますので、このサイトで紹介した
UTCを変換する関数を利用しています。

Option Explicit

Call Uptime()

'===========================================================================

Sub Uptime()

Dim OBJ_WMIService
Dim OBJ_Item
Dim COL_Item

Dim STR_Computer
Dim STR_NameSpace

Dim STR_BootUpTime
Dim STR_LocalTime
Dim STR_Work
Dim STR_Day
Dim STR_Hour
Dim STR_Min

STR_Computer = "."
STR_NameSpace = "/root/cimv2"

Set OBJ_WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & STR_Computer & STR_NameSpace)

If Err.Number <> 0 Then

WScript.Echo "Error=" & Err.Number
WScript.Echo "ERROR Code=" & Err.Number & " Description=" & Err.Description
Err.Clear
Exit Sub

End If

Set COL_Item = OBJ_WMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")

For Each OBJ_Item In COL_Item

STR_BootUpTime = OBJ_Item.LastBootUpTime
STR_LocalTime = OBJ_Item.LocalDateTime

Next

STR_BootUpTime = ConvertUTCToDate(STR_BootUpTime)
STR_LocalTime = ConvertUTCToDate(STR_LocalTime)

STR_Work = DateDIff("n", STR_BootUpTime, STR_LocalTime)

STR_Day = Fix((STR_Work / 60 ) / 24)
STR_Hour = (STR_Work / 60) Mod 24
STR_Min = STR_Work Mod 60

WScript.Echo "起動時刻: " & STR_BootUpTime
WScript.Echo "経過時間: " & STR_Day & " 日 " & STR_Hour & " 時間 " & STR_Min & " 分"

End Sub

'===========================================================================

Function ConvertUTCToDate(STR_DateTime)

ConvertUTCToDate = CDate(Mid(STR_DateTime, 5, 2) & "/" & _
Mid(STR_DateTime, 7, 2) & "/" & Left(STR_DateTime, 4) & " " & _
Mid(STR_DateTime, 9, 2) & ":" & _
Mid(STR_DateTime, 11, 2) & ":" & _
Mid(STR_DateTime, 13, 2))

End Function

31 Comments

  1. fullz cvv shop says:

    … [Trackback]

    […] Here you will find 38649 more Information to that Topic: dragon-ark.com/archives/302 […]

  2. ถาดกระดาษ says:

    … [Trackback]

    […] Find More Info here on that Topic: dragon-ark.com/archives/302 […]

  3. Psilocybe Cubensis says:

    … [Trackback]

    […] Here you will find 5247 more Information on that Topic: dragon-ark.com/archives/302 […]

  4. Construction Surveillance says:

    … [Trackback]

    […] Read More to that Topic: dragon-ark.com/archives/302 […]

  5. হোটেল রেডিসন says:

    … [Trackback]

    […] Find More Info here on that Topic: dragon-ark.com/archives/302 […]

  6. relx says:

    … [Trackback]

    […] Here you can find 82393 more Info to that Topic: dragon-ark.com/archives/302 […]

  7. slot999 says:

    … [Trackback]

    […] Read More on that Topic: dragon-ark.com/archives/302 […]

  8. sexy girls of tik tok thots compilation says:

    … [Trackback]

    […] Read More here to that Topic: dragon-ark.com/archives/302 […]

  9. 【WSH】起動時間・起動してからの経過時間を表示する | Dragon-Ark says:

    Best Proxies

    WSHを使用して、OSの起動時間と起動してからの経過時間を表示する例です。 WMIで各値…

  10. Firearms For Sale says:

    … [Trackback]

    […] Info to that Topic: dragon-ark.com/archives/302 […]

  11. สล็อตวอเลท ไม่มีขั้นต่ำ says:

    … [Trackback]

    […] Info on that Topic: dragon-ark.com/archives/302 […]

  12. 【WSH】起動時間・起動してからの経過時間を表示する | Dragon-Ark says:

    Gsa Ser Proxy

    WSHを使用して、OSの起動時間と起動してからの経過時間を表示する例です。 WMIで各値…

  13. 【WSH】起動時間・起動してからの経過時間を表示する | Dragon-Ark says:

    Orval Ainley

    WSHを使用して、OSの起動時間と起動してからの経過時間を表示する例です。 WMIで各値…

  14. dumps pin sites says:

    … [Trackback]

    […] Here you can find 96857 additional Info to that Topic: dragon-ark.com/archives/302 […]

  15. legit shop dumps says:

    … [Trackback]

    […] Find More Information here to that Topic: dragon-ark.com/archives/302 […]

Leave a Reply