Search  
Saturday, September 04, 2010 ..:: Forums ::.. Register  Login
 Forums Minimize
SearchForum Home
     
  Free stuff  Free Tools discussion  BITS 2.5 detect...
 BITS 2.5 detection utility
 
dcastate
2 posts
Joined
3/22/2010

BITS 2.5 detection utility
Posted: 22 Mar 10 7:41 PM Modified By dcastate  on 3/25/2010 12:08:59 PM)
Tried to email to support@smsutils.com but it bounced.. If you send me a working email, i will resend including modified VBS.

I saw your EXCELENT BITS 2.0 detection utility for SMS on the “Free community tools” area of your website, and I wanted to share with you. I needed to detect BITS 2.5 clients (SP3 or SP2 + in environment, and wanted to provide back for you. Really appreciate your code being available, please feel free to update with changes for others to use. I went ahead and modified the bits25mif.vbs to detect bits 2.5 (see bits25mif.vbs in attachment). I believe MOF file does not have to change at all for this to work with BITS 2.5 detection. Thanks!!!!


Changes: Altered SP1 vs SP2 logic to handle SP3 and KB923845

Replace line 30 with following line: strBitsHotfixRegPath = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Hotfix\KB923845"

Replace line 53 with following line: If strRegValue = "Service Pack 2"

Replace Line 67 with following lines:
IF strCSDVersion = "Service Pack 3" Then
strBitsHotfixInstalled = "True"
Else
strBitsHotfixInstalled = "NA"
End if
dcastate
2 posts
Joined
3/22/2010

Re: BITS 2.5 detection utility
Posted: 25 Mar 10 12:11 PM

Well, can't upload the modified VBS..so is bits25mif.vbs file inline. Use this with the free bits detection tool MOF to detect bits 2.5 clients (Windows XP) in your environment.

'==========================================================================
'
' VBScript Source File --
'
' NAME: BITS2MIF.vbs
'
' AUTHOR: Tim Mintner
' Company: SMSUtils
' For support information contact support@smsutils.com
' DATE  : 5/10/2005
'
' COMMENT: This reads the current BITS settings and creates a MIF file with
' all of the BITS settings
' Usage: cscript.exe bits2mif.vbs /kick(optional forces a Hardware Inventory)
'==========================================================================

Option Explicit
On Error Resume Next

Dim objFSO, WshShell, objNet
Dim strQuote
Dim blnCreateMIF
Dim objMIF, strMIFFileName, strNoidmifsFolder
Dim strComputerName, strUserName, strWinDir
Dim intErrNum, strErrDesc
Dim strBITSregpath,strEnableBitsMaxBandwidth,strMaxBandwidthValidFrom,strMaxBandwidthValidto
Dim strMaxTransferRateoffScheduleValue,strMaxTransferRateonscheduleValue
Dim strEnableBitsMaxBandwidthValue,strMaxBandwidthValidFromValue,strMaxBandwidthValidtoValue
Dim strMaxTransferRateoffSchedule,strMaxTransferRateonschedule
Dim strWindowsNTCurrentVersionPath,strCSDVersion, strCSDVersionRegValue
Dim strBitsHotfixRegPath, strBITSHotfixRegValue,strBitsHotfixInstalled, strKick
Dim cpapplet,actions,action
Dim blnReg
Dim strKeyPath, strValueName, strRegValue

Const ForReading = 1, ForWriting = 2
strQuote = Chr(34)
blnCreateMIF = False

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNet = WScript.CreateObject("WScript.Network")

strComputerName = objNet.ComputerName

strWindowsNTCurrentVersionPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strCSDVersionRegValue = "CSDVersion"
strBitsHotfixRegPath = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Hotfix\KB923845"
strBITSHotfixRegValue = "Installed"

blnReg = GetReg(strWindowsNTCurrentVersionPath,strCSDVersionRegValue)

If strRegValue = "Service Pack 2" Then
 strCSDVersion = strRegValue

 blnReg = GetReg(strBitsHotfixRegPath,strBITSHotfixRegValue)
 
 If strRegValue = "0" or strRegValue = "" Then
    strBitsHotfixInstalled = "False"
 Else
    Call GetBitsValues
    strBitsHotfixInstalled = "True"
 End if  
 
Else
 strCSDVersion = strRegValue
IF strCSDVersion = "Service Pack 3" Then
    strBitsHotfixInstalled = "True"
Else
 strBitsHotfixInstalled = "NA"
 End if
Call GetBITSValues
End If

 

strNoidmifsFolder = objFSO.GetSpecialFolder(0) & "\SYSTEM32\CCM\Inventory\noidmifs"
strMIFFileName = strNoidmifsFolder & "\BITS-" & strComputerName & ".mif"

 

Set objMIF = objFSO.CreateTextFile(strMIFFileName, True)
Call CreateMif

strKick = WScript.Arguments.Item(0)
If strKick = "/kick" Then
  Call ForceHardwareInventory
End if


WScript.Quit

'*************************************************************************************
'***********************        END OF SCRIPT       **********************************
'*************************************************************************************

Sub GetBitsValues
strBITSregpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\BITS"
strMaxTransferRateoffScheduleValue = "MaxTransferRateOffSchedule"
strEnableBitsMaxBandwidthValue = "EnableBITSMaxBandwidth"
strMaxBandwidthValidFromValue = "MaxBandwidthValidFrom"
strMaxBandwidthValidtoValue = "MaxBandwidthValidTo"
strMaxTransferRateonscheduleValue = "MaxTransferRateOnSchedule"

blnReg = GetReg(strBITSregpath,strMaxTransferRateoffScheduleValue)
If blnReg = True Then
  strMaxTransferRateoffSchedule = strRegValue
Else
  strMaxTransferRateoffSchedule = ""
End If

blnReg = GetReg(strBITSregpath,strEnableBitsMaxBandwidthValue)
If blnReg = True Then
  strEnableBitsMaxBandwidth = strRegValue
Else
  strEnableBitsMaxBandwidth = ""
End If

blnReg = GetReg(strBITSregpath,strMaxBandwidthValidFromValue)
If blnReg = True Then
  strMaxBandwidthValidFrom = strRegValue
Else
  strMaxBandwidthValidFrom = ""
End If

blnReg = GetReg(strBITSregpath,strMaxBandwidthValidtoValue)
If blnReg = True Then
  strMaxBandwidthValidto = strRegValue
Else
  strMaxBandwidthValidto = ""
End If

blnReg = GetReg(strBITSregpath,strMaxTransferRateonscheduleValue)
If blnReg = True Then
  strMaxTransferRateonschedule = strRegValue
Else
  strMaxTransferRateonschedule = ""
End If

End Sub

Sub ForceHardwareInventory
Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
    If Instr(action.Name,"Hardware Inventory") > 0 Then
       ' WScript.Echo action.Name
        action.PerformAction   
 End If
Next
End Sub


Function GetReg(strKeyPath,strValueName)


 GetReg = False
    strRegValue = ""
 On Error Resume Next
 strRegValue = WshShell.RegRead(strKeyPath & "\" & strValueName)
 If Err.Number <> 0 Then
  
  
  intErrNum = Err.Number
  strErrDesc = Err.Description
  On Error Goto 0
  'WScript.Echo intErrNum & vbTab & strErrDesc
 
  Select Case Left(strErrDesc, 28)
   Case "Invalid root in registry key"
    'On Error Goto 0
    'wscript.echo "Key doesn't exist"
    WshShell.LogEvent 0, "Registry key not found - skipping MIF creation"
   Case "Unable to open registry key "
    'On Error Goto 0
    'WScript.Echo "Key exists-no value"
    WshShell.LogEvent 0, "Registry value not found - skipping MIF creation"
   Case Else
    'On Error Goto 0
    'WScript.Echo "unknown error"
    WshShell.LogEvent 0, "Unknown error getting registry value - skipping MIF creation" & _
     VbCrLf & intErrNum & ": " & strErrDesc
  End Select
 
 Else
  
  GetReg = True
 End If
 
 On Error Goto 0

End Function

Sub CreateMif

 'Create Component and
 objMIF.WriteLine("Start Component")
 objMIF.WriteLine("    Name = " & strQuote & "Workstation" & strQuote) 
 objMIF.WriteLine("    Start Group")
 objMIF.WriteLine("        Name  = " & strQuote & "BITS" & strQuote)
 objMIF.WriteLine("        ID    = 1")
 objMIF.WriteLine("        Class = " & strQuote & "SMS Utils|BITS Settings" & strQuote)

 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "ComputerName" & strQuote)
 objMIF.WriteLine("            ID      = 1")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strComputerName & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "ServicePackLevel" & strQuote)
 objMIF.WriteLine("            ID      = 2")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strCSDVersion & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "BITSPatchInstalled" & strQuote)
 objMIF.WriteLine("            ID      = 3")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strBitsHotfixInstalled & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "BitsThrottlingEnabled" & strQuote)
 objMIF.WriteLine("            ID      = 4")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strEnableBitsMaxBandwidth & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "ThrottleOnHoursStartTime" & strQuote)
 objMIF.WriteLine("            ID      = 5")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strMaxBandwidthValidFrom & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "ThrottleOnHoursEndTime" & strQuote)
 objMIF.WriteLine("            ID      = 6")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strMaxBandwidthValidTo & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "ThrottleSpeedOnHours" & strQuote)
 objMIF.WriteLine("            ID      = 7")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strMaxTransferRateonschedule & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("        Start Attribute")
 objMIF.WriteLine("            Name    = " & strQuote & "ThrottleSpeedOffHours" & strQuote)
 objMIF.WriteLine("            ID      = 8")
 objMIF.WriteLine("            Type    = String(50)")
 objMIF.WriteLine("            Storage = Specific")
 objMIF.WriteLine("            Value   = " & strQuote & strMaxTransferRateoffschedule & strQuote)
 objMIF.WriteLine("        End Attribute")
 objMIF.WriteLine("    End Group")
 objMIF.WriteLine("End Component")

End Sub

 

 

 

  Free stuff  Free Tools discussion  BITS 2.5 detect...

Forum Home  Search         

Copyright 2006 SMSUtils   Terms Of Use  Privacy Statement