每天上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的共享路徑。