2015年5月7日 星期四

用vb script 取得 電腦名稱,ip,電腦廠牌型號序號

strComputer = "."
str_pcmodel = ""
str_serialnumber=""
str_hostname=""
str_outstring=""
str_username=""
str_regread=""
dim objshell
str_username = "username: " & CreateObject("WScript.Network").UserName & vbCrlf

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")
For each objBIOS in colBIOS
 
str_serialnumber = "PC SERIAL NUMBER: " & objBIOS.SerialNumber &vbCrlf
 
Next


Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
     str_pcmodel = "PC MODEL: " & objComputer.Model &vbCrlf
    str_hostname = "Host NAME: " & objComputer.Name &vbCrlf
   
 
 
Next

str_outstring = str_username & str_pcmodel & str_serialnumber & str_hostname

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 Each strAddress in IPConfig.IPAddress
    str_outstring = str_outstring & "IP: " & strAddress &vbCrlf
  Next
  End If
Next

str_regread="HKEY_LOCAL_MACHINE\SOFTWARE\ATI\ACE\Apps\EEU\FILE"

Set objShell = WScript.CreateObject("WScript.Shell")

str_regread = "Owner: " & objShell.RegRead(str_regread) &vbCrlf

str_outstring = str_outstring & str_regread

'Wscript.Echo str_outstring
MsgBox str_outstring , vbOKOnly ,str_hostname