Mass Removal of Microsoft Security Essentials

There's a good chance this content may be outdated!

This post is 4 years old—a long time on the internet. Any content within is provided as-is and is not guaranteed to work on modern systems - your mileage may vary.

DANGER, WILL ROBINSON! DANGER! THIS ARTICLE IS OVER A YEAR OLD AND IS POSSIBLY OUT OF DATE! THE INFORMATION CONTAINED WITHIN MAY NOT BE ACCURATE ANYMORE! PROCEED WITH CAUTION!

Microsoft_Security_Essentials_icon

At work, we have finally grown up. By that, I mean we finally have a centralized antivirus product that is actually up to date and doesn’t suck as bad as the old Symantec antivirus we were using. As a replacement, we used Security Essentials and the only thing that moved us to a new platform was the fact that we were technically out of compliance with the MSE license. In a business environment, Microsoft allows you to have only 10 copies installed on computers. We were past that. By like a lot.

One of the challenges of moving to our new AV solution was removing this program from our computers en masse. With several sites and many versions of MSE, you can bet that this was no easy task. Well, since I’m your typical lazy network administrator, I don’t have the time to sit there and manually remove every installation… so I automated it with a shut down script!

This script is a batch file that runs on shut down (or you could run it on start up if you really wanted). Originally, I found a VBS script that caused the computers to hang for about 10 minutes or so on shutdown every time. I’m not a VBS person at all… I love batch files and Powershell, and since I couldn’t Powershell this, I batched it!

The code to use:

@echo off

if exist "%ProgramFiles%/Microsoft Security Essentials" (
START /wait "Uninstalling MSE" "%ProgramFiles%/Microsoft Security Essentials/setup.exe" /x 

/s
) else (
if exist "%ProgramFiles%/Microsoft Security Client" (
START /wait "Uninstalling MSE" "%ProgramFiles%/Microsoft Security Client/setup.exe" /x /s
) else (
exit
)
)
)

Save this as a batch file and create a shutdown (or startup) GPO and have it run this batch file.

Here’s what it does:

  1. Does the path %ProgramFiles%/Microsoft Security Essentials exist? Yes? Run Setup.exe with silent parameters and uninstall parameters. No? Go on to the next line.
  2. Does the path %ProgramFiles%/Microsoft Security Client exist? Yes? Run Setup.exe with silent parameters and uninstall parameters. No? Go on to the next line.
  3. Exit.

This way there is an escape clause and there is no hang up and if there’s an older version of MSE installed, it’s removed as well.

 

 

9 Comments

    • Hi there – this may still work. I haven’t used any of the latest versions of MSE so I’m going to say it will but mileage may vary.

  1. A little late to the party, but any idea why this would work as a startup script, but not as a shutdown script?

    • That’s a good question, Michael. I might fire this up in a Windows 7 lab environment and give it a try to see what I can find.

  2. Just need to correct some slashes to backslashes, but works beautifully.

    For example: “%ProgramFiles%/Microsoft Security Essentials/setup.exe”

    Should be: “%ProgramFiles%\Microsoft Security Essentials\setup.exe”

    Thank you!

Leave a Reply