System Administration Scripting

2007年4月30日星期一

将“我的电脑”更名为:电脑名+登陆用户名+IP

Const MY_COMPUTER = &H11&
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
参考:利用脚本在我的电脑上显示IP地址或是机器名

Bookmark this post:
Ma.gnolia DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google


0 评论:

相关文章

©2007