Const MY_COMPUTER = &H11&参考:利用脚本在我的电脑上显示IP地址或是机器名
Set objNetwork = CreateObject("Wscript.Network")
objComputerName = objNetwork.ComputerName
objUserName = objNetwork.UserName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strComputer = "."
strMY_IP = ""
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)
IP = IPConfig.IPAddress(i)
If InStr(IP,"10.14.") Then
strMY_IP = IP
End If
Next
End If
Next
objFolderItem.Name = objComputerName + vbCrLf + objUserName + vbCrLf + strMY_IP
Bookmark this post:
|
0 评论:
发表评论