''******************************************************************************
'* scriptenv.vbs
'* Gets versions of OS, WSH, WMI & ADSI on local machine
'* and determines which are up-to-date.
'******************************************************************************
'******************************************************************************
'* Call functions to get information on default WSH host.
'* If Wscript.exe, temporarily change to Cscript.exe
'******************************************************************************
'******************************************************************************
'* Connect to WMI Service.
'******************************************************************************
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & strNamespace)
If Err.Number <> 0 Then
WScript.Echo "Error 0x" & hex(Err.Number) & " " & _
Err.Description & ". " & VbCrLf & _
"Unable to connect to WMI. WMI may not be installed."
Err.Clear
WScript.Quit
End If
'******************************************************************************
'* Call functions to get information on OS, WSH, WMI and ADSI.
'******************************************************************************
'******************************************************************************
'* Call sub to list which versions are current.
'******************************************************************************
If Err.Number <> 0 Then
WScript.Echo "Error 0x" & hex(Err.Number) & " " & _
Err.Description & ". " & VbCrLf & strErrorMessage
Err.Clear
Exit Function
End If
If IsNull(strFullName) Then
WScript.Echo strErrorMessage
Exit Function
End If
strWshHost = Right(LCase(strFullName), 11)
If Not((strWshHost = "wscript.exe" Or (strWshHost = "cscript.exe") Then
WScript.Echo strErrorMessage
Exit Function
End If
GetWshHost = strWshHost
End Function
'******************************************************************************
'* If default Windows Script Host is Wscript, change to Cscript.
'******************************************************************************
Sub ChangeToCscript(strWshHost)
If strWshHost = "wscript.exe" Then
Set objShell = CreateObject("WScript.Shell"
objShell.Run _
"%comspec% /k ""cscript //h:cscript&&cscript scriptenv.vbs""", _
MAXIMIZE_WINDOW
If Err.Number <> 0 Then
WScript.Echo "Error 0x" & hex(Err.Number) & " occurred. " & _
Err.Description & ". " & VbCrLf & _
"Could not temporarily change the default script host to Cscript."
Err.Clear
WScript.Quit
End If
WScript.Quit
End If
End Sub
'******************************************************************************
'* Get OS information.
'******************************************************************************
Select Case intOSType
Case 16 'Windows 95
intOSVer = 1
Case 17 'Windows 98
intOSVer = 2
' Note: Windows Millennium is not included as an OSType by WMI.
Case 18
Select Case strOSVer
Case 4.0
intOSVer = 4 'Windows NT 4.0
Case 5.0
intOSVer = 5 'Windows 2000
Case 5.1
intOSVer = 6 'Windows XP
Case 5.2
intOSVer = 7 'Windows Server 2003
Case Else
intOSVer = 0 'Older or newer version
End Select
Case Else
intOSVer = 0 'Older or newer version
End Select
If (intOSVer >= 1 And intOSVer <= 5) Then
strWmiVer = "1.5"
ElseIf intOSVer = 6 Then
strWmiVer = "5.1"
ElseIf intOSVer = 7 Then
strWmiVer = "5.2"
Else
strWmiVer = "?.?"
End If
Set colWMISettings = objWMIService.ExecQuery _
("Select * from Win32_WMISetting"
For Each objWMISetting In colWMISettings
Wscript.Echo "Windows Management Instrumentation" & vbCrLf & _
"==================================" & vbCrLf & _
"WMI Version & Build: " & _
strWmiVer & "." & objWMISetting.BuildVersion & vbCrLf & _
"Default scripting namespace: " & _
objWMISetting.ASPScriptDefaultNamespace & vbCrLf
dblBuildVersion = CDbl(objWMISetting.BuildVersion)
Next
If (intOSVer = 7 And dblBuildVersion >= 3790.0000) Or _
(intOSVer = 6 And dblBuildVersion >= 2600.0000) Or _
(intOSVer <= 5 And dblBuildVersion >= 1085.0005) _
Then
GetWMIVer = True
Else
GetWMIVer = False
End If
End Function
'******************************************************************************
'* Display ADSI provider and version information.
'******************************************************************************
If strAdsiVer = vbEmpty Then
strAdsiVer = _
objShell.RegRead("HKLM\SOFTWARE\Microsoft\ADs\Providers\LDAP"
If strAdsiVer = vbEmpty Then
strAdsiVer = "ADSI is not installed."
Else
strAdsiVer = "2.0"
End If
ElseIf Left(strAdsiVer, 3) = "5,0" Then
If intOSVer = 5 Then
strAdsiVer = "5.0.2195"
ElseIf intOSVer = 6 Then
strAdsiVer = "5.1.2600"
ElseIf intOSVer = 7 Then
strAdsiVer = "5.2.3790"
Else
strAdsiVer = "?.?"
End If
End If
WScript.Echo "ADSI Version & Build: " & strAdsiVer & VbCrLf
If strAdsiVer <> "ADSI is not installed." Then
Set colProvider = GetObject("ADs:"
Wscript.Echo "ADSI Providers" & VbCrLf & _
"--------------"
For Each objProvider In colProvider
Wscript.Echo objProvider.Name
Next
Wscript.Echo
End If
intAdsiVer = CInt(Left(strAdsiVer, 1))
If (intOSVer = 7 And intAdsiVer >= 5) Or _
(intOSVer = 6 And intAdsiVer >= 5) Or _
(intOSVer = 5 And intAdsiVer >= 5) Or _
(intOSVer = 4 And intAdsiVer >= 2) Or _
(intOSVer <= 3 And intAdsiVer >= 2) _
Then
GetADSIVer = True
Else
GetADSIVer = False
End If
End Function
'******************************************************************************
'* Test for current versions and display results.
'******************************************************************************
Sub ListUpToDate(blnWSHUpToDate, blnWMIUpToDate, blnADSIUpToDate)
If blnWSHUpToDate Then
WScript.Echo "WSH version: most recent for OS version."
Else
WScript.Echo "WSH version: not most recent for OS version."
If intOSVer = 0 Then
WScript.Echo "Windows Script not available for this OS"
Else
WScript.Echo "Get Windows Script 5.6, Build 8515"
End If
End If
If blnWMIUpToDate Then
WScript.Echo "WMI version: most recent for OS version."
Else
WScript.Echo "WMI version: not most recent for OS version."
If intOSVer = 0 Then
WScript.Echo "WMI not available for this OS"
ElseIf intOSVer >= 1 And intOSVer <= 4 Then
WScript.Echo "Get WMI CORE 1.5"
Else
End If
End If
If blnADSIUpToDate Then
WScript.Echo "ADSI version: most recent for OS version."
Else
WScript.Echo "ADSI version: not most recent for OS version."
If intOSVer = 0 Then
WScript.Echo "ADSI not available for this OS"
ElseIf intOSVer >= 1 And intOSVer <= 4 Then
WScript.Echo "Get Active Directory Client Extensions"
Else
End If
End If
End Sub
===========================================================
nice little script from m$ to find the patch levels of different things.
just grep thru it for what u need
job sheduling is done thru .job files in the %windir%\tasks directory. You can copy them from a network share but they won't keep any account name and password saved.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.