?
Solved

Automated Way to Unistall Windows Defender

Posted on 2007-07-26
6
Medium Priority
?
314 Views
Last Modified: 2009-01-09
I would like to automate an Unistall/Remove for Microsoft's Window Defender for my Entire Company. We utilize Active Directory GPO's and Login Scripts so I could use those means to do it if it is possible. Is there a way to do this?
I tried this batch file but it was unsuccesful:
msiexec /uninstall windowsdefender.msi /quiet /log uninstall.log
Thanks!
0
Comment
Question by:GCSTeam
  • 4
5 Comments
 
LVL 4

Expert Comment

by:aces4all
ID: 19596891
Try something like this in vbscript

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
      "Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _ 'Replace with the LDAP path for your domain
            & "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
      RemoveDefender(objRecordSet.Fields("Name").Value)
      objRecordSet.MoveNext
Loop

Sub RemoveDefenfer(strComputer)
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colSoftware = objWMIService.ExecQuery _
            ("Select * from Win32_Product Where Name = 'Windows Defender'")
      For Each objSoftware in colSoftware
            objSoftware.Uninstall()
      Next
End Sub
0
 
LVL 4

Expert Comment

by:aces4all
ID: 19596900
SJust saw a type try the following instead and replace Windows Defender with the actual name of the application as it appears in Add/remove programs:

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
      "Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _ 'Replace with the LDAP path for your domain
            & "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
      RemoveDefender(objRecordSet.Fields("Name").Value)
      objRecordSet.MoveNext
Loop


Sub RemoveDefenfer(strComputer)
      Set objWMIService = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colSoftware = objWMIService.ExecQuery _
            ("Select * from Win32_Product Where Name = 'Windows Defender'")
      For Each objSoftware in colSoftware
            objSoftware.Uninstall()
      Next
End Sub
0
 

Author Comment

by:GCSTeam
ID: 19604118
Hi,
Thanks so much. This looks like the type of solution I am looking for, but this script errors out on me on line 24. Do you have any suggestions?
0
 
LVL 4

Expert Comment

by:aces4all
ID: 19604416
More typos.  Try this:

Option Explicit

Const ADS_SCOPE_SUBTREE = 2

Dim objConnection, objCommand, objRecordSet

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
      "Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
            & "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
      RemoveDefender(objRecordSet.Fields("Name").Value)
      objRecordSet.MoveNext
Loop


Sub RemoveDefender(strComputer)
      Dim objWmiService, colSoftware, objSoftware

      Set objWMIService = GetObject("winmgmts:" _
            & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colSoftware = objWMIService.ExecQuery _
            ("Select * from Win32_Product Where Name = 'Windows Defender'")
      For Each objSoftware in colSoftware
            objSoftware.Uninstall()
      Next
End Sub
0
 
LVL 4

Accepted Solution

by:
aces4all earned 500 total points
ID: 19604437
Be sure to replace 'LDAP://DC=fabrikam,DC=com' with the ldap path to your domain and 'Windows Defender' with the name of Windows Defender as it appears in Add/remove programs.

Let me know if there are any more errors and what they are.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question