回复 1# zdv478
简单写写,前半截:- ' 2>nul 3>nul&cls&@echo off
- '&rem 获取本机系统及硬件配置信息
- '&cd /d "%~dp0"
- '&cscript -nologo -e:vbscript "%~fs0">info.txt
- '&pause&exit
-
- On Error Resume Next
- Set fso=CreateObject("Scripting.Filesystemobject")
- Set ws=CreateObject("WScript.Shell")
- Set wmi=GetObject("winmgmts:\\.\root\cimv2")
-
- WSH.echo "---------------我的电脑-------------"
- Set query=wmi.ExecQuery("Select * from Win32_ComputerSystem")
- For each item in query
- WSH.echo "电脑名称:" & item.Name
- Next
-
- Set query=wmi.ExecQuery("Select * from Win32_OperatingSystem")
- For each item in query
- WSH.echo "电脑系统:" & item.Caption & "[" & item.Version & "]"
- WSH.echo "安装日期:" & UTCtoNow(item.InstallDate)
- visiblemem=item.TotalVisibleMemorySize
- virtualmem=item.TotalVirtualMemorySize
- Next
-
- 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'")
- For Each objEvent In colLoggedEvents
- Flag = Flag +1
- If Flag = 1 Then
- startTime=UTCtoNow(objEvent.TimeWritten)
- End If
- Next
-
- CurrentDate = year(Now) &"-"& Month(Now) &"-"& day(Now)
- CurrentTime = Hour(Now) &":"& Minute(Now) &":"& Second(Now)
-
- currentTime = CurrentDate &" "& CurrentTime
-
- difMinute = datediff("s",startTime,currentTime ) / 60 / 60
- difM = round(difMinute,2)
- m=Round(split(difM,".")(1)*60/100,0)
- h=split(difM,".")(0)
-
- Wscript.Echo "运行时长:" & h &" 小时 "& m &" 分钟"
-
- Set query=wmi.ExecQuery("Select * from Win32_NetworkAdapter Where NetConnectionID !=null and not Name like '%Virtual%'")
- For each item in query
- Set query2=wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where Index=" & item.Index)
- For each item2 in query2
- If typeName(item2.IPAddress) <> "Null" Then
- WSH.echo "本机IP:" & item2.IPAddress(0)
- If typeName(item2.DNSServerSearchOrder) <> "Null" Then
- WSH.echo "DNS1:" & item2.DNSServerSearchOrder(0)
- WSH.echo "DNS2:" & item2.DNSServerSearchOrder(1)
- End If
- End If
- Next
- Next
-
- WSH.echo
- WSH.echo "---------------硬件信息-------------"
-
-
- Function FormatSize(byVal t)
- If t >= 1099511627776 Then
- FormatSize = FormatNumber(t/1099511627776, 2, true) & " TB"
- ElseIf t >= 1073741824 Then
- FormatSize = FormatNumber(t/1073741824, 2, true) & " GB"
- ElseIf t >= 1048576 Then
- FormatSize = FormatNumber(t/1048576, 2, true) & " MB"
- ElseIf t >= 1024 Then
- FormatSize = FormatNumber(t/1024, 2, true) & " KB"
- Else
- FormatSize = t & " B"
- End If
- End Function
-
- Function UTCtoNow(nD)
- If Not IsNull(nD) Then
- Set SWDT = CreateObject("WbemScripting.SWbemDateTime")
- SWDT.Value = nD
- UTCtoNow = SWDT.GetVarDate(True)
- End If
- End Function
复制代码
|