网上不同地方找的代码,希望实现如下功能,帮忙看怎么整合到一起输出,多谢!
1、由于不同代码不同功能,输出是好几个界面,现希望将这几个功能的输出内容界面合并输出到一个界面来显示;
2、将最终合并输出的内容以文本方式写入当前目录下的output.txt,带(是/否 输出)选项。- 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
-
- '第三部分:显示“IP、MAC地址”(如果 第一部分 可以实现显示的话,这里就不用了)
- 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(".")
-
- '第四部分:win10 序列号查看器(如果 第一部分 可以实现显示的话,这里就不用了)
- 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 Function
复制代码
|