gpt4 book ai didi

VBS中获取系统本次及上次开关机时间的代码(WinXP/win2003/Win7兼容版)

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 27 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章VBS中获取系统本次及上次开关机时间的代码(WinXP/win2003/Win7兼容版)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

复制代码 代码如下

If (Lcase(Right(Wscript.FullName,11)) = "wscript.exe") Then CreateObject("WScript.Shell").Run("%Comspec% /C " &Chr(34)&"mode con cols=100&Cscript.exe //NoLogo "&Chr(34)& Wscript.ScriptFullName &Chr(34)&"&&(Echo 此窗口40秒后自动关闭...&Ping -n 40 127.0.1>nul&Exit)"&Chr(34)),3:Wscript.Quit Wscript.Quit End If Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colLoggedEvents = WMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' And EventCode = '6005' Or EventCode = '6006' Or EventCode = '6008'") For Each objEvent In colLoggedEvents Flag = Flag + 1 If Flag = 1 Then Wscript.Echo "本次开机时间: " & UTCtoNow(objEvent.TimeWritten) ElseIf (Flag Mod 2) = 0 Then G = UTCtoNow(objEvent.TimeWritten) Else K = UTCtoNow(objEvent.TimeWritten) Wscript.Echo "前次开机:"&K&" "&vbTab&"对应关机:"&G&" "&vbTab& "运行时长:" &StoHMS(DateDiff("s", K, G)) End If Next Function UTCtoNow(nD) If Not IsNull(nD) Then Set SWDT = CreateObject("WbemScripting.SWbemDateTime") SWDT.Value = nD UTCtoNow = SWDT.GetVarDate(True) End If End Function Function StoHMS(Sec) H = Int(Sec/3600) :H1 = Sec Mod 3600:M = Int(H1/60) :S = H1 Mod 60 StoHMS = H & "小时" & M & "分钟" & S &"秒" End Function 。

最后此篇关于VBS中获取系统本次及上次开关机时间的代码(WinXP/win2003/Win7兼容版)的文章就讲到这里了,如果你想了解更多关于VBS中获取系统本次及上次开关机时间的代码(WinXP/win2003/Win7兼容版)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com