Friday, September 10, 2004

A Quick Scripting Tip

I have been trying some WMI scripting recently and thought could post the scripts that I found useful and the ones that I succeeded executing. Here is one. This script helps the Administrator to find out which scripting technologies have been installed in the PC.

On Error Resume Next
WScript.Echo "WSH Version: " & WScript.Version
Wscript.Echo "VBScript Version: " & ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
compName = "."
Set wmiServcObject = GetObject("winmgmts:" &"{impersonationLevel=impersonate}!\\" & compName & "\root\cimv2")

Set colWMISettings = wmiServcObject.ExecQuery & ("Select * from Win32_WMISetting")
For Each objWMISetting in colWMISettings
Wscript.Echo "WMI Version: " & objWMISetting.BuildVersion
Next
Set shellObject = CreateObject("WScript.Shell")
adsiVersionIns = shellObject.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\
Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\Version")
If adsiVersionIns = vbEmpty Then
adsiVersionIns = shellObject.RegRead("HKLM\SOFTWARE\Microsoft\ADs\Providers\LDAP\")
If adsiVersionIns = vbEmpty Then
adsiVersionIns = "ADSI is not installed."
Else
adsiVersionIns = "2.0"
End If
End If
WScript.Echo "ADSI Version: " & adsiVersionIns

If you want to have the latest versions of the Scripting Technologies:

ADSI:http://www.microsoft.com/windows2000/server/evaluation/news/bulletins/adextension.asp WMI:http://www.microsoft.com/downloads/release.asp?ReleaseID=18490
WSH/VBScript:http://msdn.microsoft.com/downloads/list/webdev.asp

No comments: