每天上WINMAG社区看看现在似乎已经成了习惯,昨天在WINDOWS管理脚本区看到“mypeter”网友的“请问怎样在桌面上原来显示版本号的地方显示当前的IP地址和电脑名称呢?(基本解决)”的贴子!贴中介绍了他使用VBS与BAT脚本来实现了该功能,对此非常感兴趣,按照他的方法我经过调试在自已管理的域里也实现该功能,现将脚本公布如下,并对“mypeter”表示感谢!
1、请将下述代码存在VBS格式:
Dim ip
Dim Mac
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress,MacAddress 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)
Mac = IPConfig.MacAddress
Next
End If
Next
Const ForWriting = 8
Set lei2=WScript.CreateObject("WScript.Network")
CN=lei2.computername
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "BuildLab"
strValue = "( "&CN&" )"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "DWORD Value Name"
dwValue = 82
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "CSDVersion"
strValue = ip & " ) ( "& Mac
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "DWORD Value Name"
dwValue = 82
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
2、请将下述代码存为BAT格式:
reg add hkcu\Control" "Panel\Desktop /v PaintDesktopVersion /t REG_DWORD /d 1 /f
3、注意点:
1、需要重新启动两次。
2、启动后在登录界面等待15秒以上,再登入。
3、在WIN2000中没有BAT中REG程序,而XP系统中有,如需要在2000域中使用请将REG程序COPY到一个共享目录中,并在BAT代码中加入REG的共享路径。
转载于:https://blog.51cto.com/xxjiangsir/386560