码迷,mamicode.com
首页 > 系统相关 > 详细

vbs 脚本 获取机器名/IP/MAC

时间:2015-07-02 17:23:09      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

strComputer = "."
strMesseage=""

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

‘获取本机计算机名
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")

For Each objComputer in colSettings
strMesseage = "System Name: " & objComputer.Name & vbCr&vbCr
Next

‘获取本机IP地址
Set IPConfigSet = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each objItem In IPConfigSet
For Each objAddress In objItem.IPAddress
If objAddress <> "" And objAddress <> "0.0.0.0" Then
strMesseage = strMesseage & "IP Address: " & objAddress & vbCr&vbCr
End If
Next
Next

i=MsgBox(strMesseage, vbOKOnly&vbInformation, "System Infomation")

vbs 脚本 获取机器名/IP/MAC

标签:

原文地址:http://www.cnblogs.com/wagwei/p/4616355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!