VBScript to enable BITS
Sometimes people like to turn off BITS as a security lockdown. When that happens SMS can have issues. Here's a quick and dirty script sample to do the job.
----Begin VBScript----
On Error Resume Next
For i = 1 to 30
If Len(i) = 1 then number = "0" & i
If Len(i) = 2 then number = i
computerName = "name of your computer"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & computerName & "\root\cimv2")
WScript.Echo computerName & " " & Err
If Err = 0 Then
Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name = 'BITS'")
If Err = 0 Then
WScript.Echo computerName & vbCrLf
For Each objService in colServiceList
errReturnCode = objService.Change( , , , , "Automatic")
WScript.Echo vbTab & "Changed " & objService.Name & " to automatic"
objService.StartService()
Next
End If
Set colServiceList = nothing
End If
Set objWMIService = nothing
Next
----End VBScript----
----Begin VBScript----
On Error Resume Next
For i = 1 to 30
If Len(i) = 1 then number = "0" & i
If Len(i) = 2 then number = i
computerName = "name of your computer"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & computerName & "\root\cimv2")
WScript.Echo computerName & " " & Err
If Err = 0 Then
Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name = 'BITS'")
If Err = 0 Then
WScript.Echo computerName & vbCrLf
For Each objService in colServiceList
errReturnCode = objService.Change( , , , , "Automatic")
WScript.Echo vbTab & "Changed " & objService.Name & " to automatic"
objService.StartService()
Next
End If
Set colServiceList = nothing
End If
Set objWMIService = nothing
Next
----End VBScript----
About the Author
Emmanuel Tsouris is a Systems Management veteran and Developer Advocate specializing in PowerShell and Cloud Automation. He maintains DotVBS to preserve legacy knowledge for the "archaeologist admin."
Ready to move from VBScript to the Cloud? Check out his book, Pro PowerShell for Amazon Web Services.
Visit EmmanuelTsouris.com for his latest projects.
As an Amazon Associate, I earn from qualifying purchases at no cost to you.
Comments