| k=1 |
| Set wmiService = GetObject("winmgmts:\\.\root\cimv2") |
| Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_OperatingSystem") |
| |
| |
| For Each wmiObject In wmiObjects |
| msgbox "系统"&k&vblf&"" _ |
| &vblf&"计算机名: 不知道在这里显示的代码" _ |
| &vblf&"WinProductID: 不知道在这里显示的代码" _ |
| &vblf&"" _ |
| &vblf&"系统版本: "&wmiObject.Caption _ |
| &vblf&"安装时间: "&wmiObject.InstallDate _ |
| &vblf&"最后启动: "&wmiObject.lastbootuptime _ |
| &vblf&"能不能让时间格式显示为:2016-05-05 21:08:55 ?" _ |
| &vblf&"" _ |
| &vblf&"ip地址: 不知道在这里显示的代码" _ |
| &vblf&"MAC地址: 不知道在这里显示的代码" |
| next |
| |
| |
| Set colSettings = wmiService.ExecQuery _ |
| ("Select * from Win32_ComputerSystem") |
| For Each objComputer in colSettings |
| Wscript.Echo "System Name: " & objComputer.Name |
| |
| next |
| |
| |
| Function GetIPMAC(ComputerName) |
| Dim objWMIService,colItems,objItem,objAddress |
| Set objWMIService = GetObject("winmgmts://" & ComputerName & "/root/cimv2") |
| Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True") |
| For Each objItem in colItems |
| For Each objAddress in objItem.IPAddress |
| If objAddress <> "" then |
| GetIPMAC = "IP 地址: " & objAddress & vbNewLine & "MAC地址: " & objItem.MACAddress |
| Exit For |
| End If |
| Next |
| Exit For |
| Next |
| End Function |
| |
| WScript.Echo GetIPMAC(".") |
| |
| |
| Set WshShell = CreateObject("WScript.Shell") |
| regKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" |
| DigitalProductId = WshShell.RegRead(regKey & "DigitalProductId") |
| |
| WinProductName = "Windows Product Name: " & WshShell.RegRead(regKey & "ProductName") & vbNewLine |
| WinProductID = "Windows Product ID: " & WshShell.RegRead(regKey & "ProductID") & vbNewLine |
| WinProductKey = ConvertToKey(DigitalProductId) |
| strProductKey ="Windows Key: " & WinProductKey |
| WinProductID = WinProductName & WinProductID & strProductKey |
| |
| |
| MsgBox(WinProductID) |
| |
| |
| Function ConvertToKey(regKey) |
| Const KeyOffset = 52 |
| isWin8 = (regKey(66) \ 6) And 1 |
| regKey(66) = (regKey(66) And &HF7) Or ((isWin8 And 2) * 4) |
| j = 24 |
| Chars = "BCDFGHJKMPQRTVWXY2346789" |
| Do |
| Cur = 0 |
| y = 14 |
| Do |
| Cur = Cur * 256 |
| Cur = regKey(y + KeyOffset) + Cur |
| regKey(y + KeyOffset) = (Cur \ 24) |
| Cur = Cur Mod 24 |
| y = y -1 |
| Loop While y >= 0 |
| j = j -1 |
| winKeyOutput = Mid(Chars, Cur + 1, 1) & winKeyOutput |
| Last = Cur |
| Loop While j >= 0 |
| If (isWin8 = 1) Then |
| keypart1 = Mid(winKeyOutput, 2, Last) |
| insert = "N" |
| winKeyOutput = Replace(winKeyOutput, keypart1, keypart1 & insert, 2, 1, 0) |
| If Last = 0 Then winKeyOutput = insert & winKeyOutput |
| End If |
| a = Mid(winKeyOutput, 1, 5) |
| b = Mid(winKeyOutput, 6, 5) |
| c = Mid(winKeyOutput, 11, 5) |
| d = Mid(winKeyOutput, 16, 5) |
| e = Mid(winKeyOutput, 21, 5) |
| ConvertToKey = a & "-" & b & "-" & c & "-" & d & "-" & e |
| End FunctionCOPY |