收藏本站 收藏本站
积木网首页 - 软件测试 - 常用手册 - 站长工具 - 技术社区
首页 > VBScript > 正文

首页 - PHP - 数据库 - 操作系统 - 游戏开发 - JS - Android - MySql - Redis - MongoDB - Win8 - Shell编程 - DOS命令 - jQuery - CSS样式 - Python - Perl

Access - Oracle - DB2 - SQLServer - MsSql2008 - MsSql2005 - Sqlite - PostgreSQL - node.js - extjs - JavaScript vbs - Powershell - Ruby

查询电脑开关机时间的vbs代码

核心代码:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" _
& strComputer & "rootcimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent " _
& "Where Logfile = 'System' And EventCode = '6005' Or EventCode = '6006'")
For Each objEvent In colLoggedEvents
  Flag = Flag + 1
  If Flag = 1 Then
    Wscript.Echo "本次开机时间: " & FormatWMIUTC(objEvent.TimeWritten)
  ElseIf Flag = 2 Then
    Wscript.Echo "上次关机时间: " & FormatWMIUTC(objEvent.TimeWritten)
  ElseIf Flag = 3 Then
    Wscript.Echo "上次开机时间: " & FormatWMIUTC(objEvent.TimeWritten)
    Exit For
  End If
Next

'FormatUTC
Function FormatWMIUTC(WMIDateString)
  DS = " // :: "
  FormatWMIUTC = Left(WMIDateString,2)
  For i = 2 To 7
    FormatWMIUTC = FormatWMIUTC & Mid(WMIDateString, i * 2 - 1, 2) & Mid(DS,i,1)
  Next
  'FormatWMIUTC = Mid(WMIDateString, 1, 4) & "年" _
  '      & Mid(WMIDateString, 5, 2) & "月" _
  '      & Mid(WMIDateString, 7, 2) & "日 " _
  '      & Mid (WMIDateString, 9, 2) & ":" _
  '      & Mid(WMIDateString, 11, 2) & ":" _
  '      & Mid(WMIDateString,13, 2)
End Function

将上面的代码保存为vbs后缀的文件,双击运行即可。看到这次的开机时间,上次的开关机时间。

查看图片

通过vbs修改以点结尾的文件的属性为隐藏
核心代码:rem修改以点结尾的文件的属性为隐藏@echooffsetDstFile=C:testbatcher."%temp%FileProperty.vbs"echoSetobjFSO=CreateObject("Scripting.FileSystemObject").GetFile("\%DstFile

杀死指定进程名称的小VBS
以下是一小段杀死指定进程名字的小vbs,希望对大家有帮助。FunctionKillProc(strProcName)OnErrorResumeNextSetobjWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\.

使用vbs获取雅虎汇率
使用vbs获取雅虎汇率Functionbytes2bstr(vin)strreturn=""fori=1tolenb(vin)thischarcode=ascb(midb(vin,i,1))ifthischarcode&h80thenstrreturn=strreturn&chr(thischarcode)elsenextcharcode=ascb(midb(vin

本周排行

更新排行

强悍的草根IT技术社区,这里应该有您想要的!
Copyright © 2010 Gimoo.Net. All Rights Rreserved  京ICP备05050695号