Deploy Windows Malicious Software Removal Tool in an enterprise environment

Applies to: Windows 7 Enterprise NWindows 7 Home BasicWindows 7 Home Premium More

The Windows Malicious Software Removal Tool is intended for use with the operating systems that are listed in the "Applies to" section. Operating systems that are not included in the list were not tested and therefore are not supported. These unsupported operating systems include all versions and editions of embedded operating systems.

Introduction


Microsoft generally releases Windows Malicious Software Removal Tool (MSRT) monthly as part of Windows Update or as the standalone tool. Use this tool to find and remove specific prevalent threats and reverse the changes they have made (see covered threats). For comprehensive malware detection and removal, consider using Microsoft Safety Scanner.

This tool works in a complementary manner with existing antimalware solutions and can be used on most current Windows versions (see Properties section).

The information contained in this article is specific to the enterprise deployment of the tool. We recommend that you review the following knowledge base article for more information about the tool:

Deployment overview


The tool can be deployed in an enterprise environment to enhance existing protection and as part of a defense-in-depth strategy. To deploy the tool in an enterprise environment, you can use one or more of the following methods:

  • Windows Server Update Services
  • Microsoft Systems Management Software (SMS) software package
  • Group Policy-based computer startup script
  • Group Policy-based user logon script

The current version of this tool does not support the following deployment technologies and techniques:

  • Windows Update Catalog
  • Execution of the tool against a remote computer
  • Software Update Services (SUS)

Additionally, the Microsoft Baseline Security Analyzer (MBSA) does not detect execution of the tool. This article includes information about how you can verify execution of the tool as part of deployment.

Code sample


The script and the steps that are provided here are meant to be only samples and examples. Customers must test these sample scripts and example scenarios and modify them appropriately to work in their environment. You must change the ServerName and the ShareName according to the setup in your environment.

The following code sample does the following things:

  • Runs the tool in silent mode
  • Copies the log file to a preconfigured network share
  • Prefixes the log the file name by using the name of the computer from which the tool is run and the user name of the current user

    Note You must set appropriate permissions on the share according to the instructions in the Initial setup and configuration section.
REM In this example, the script is named RunMRT.cmd.REM The Sleep.exe utility is used to delay the execution of the tool when used as a REM startup script. See the "Known issues" section for details.@echo offcall \\ServerName\ShareName\Sleep.exe 5Start /wait \\ServerName\ShareName\Windows-KB890830-V5.70.exe /qcopy %windir%\debug\mrt.log \\ServerName\ShareName\Logs\%computername%_%username%_mrt.log

Note In this code sample, ServerName is a placeholder for the name of your server, and ShareName is a placeholder for the name of your share.

Initial setup and configuration


This section is intended for administrators who are using a startup script or a logon script to deploy this tool. If you are using SMS, you can continue to the "Deployment methods" section.

To configure the server and the share, follow these steps:

  1. Set up a share on a member server. Then name the share
    ShareName.
  2. Copy the tool and the sample script, RunMRT.cmd, to the share. See the Code sample section for details.
  3. Configure the following share permissions and NTFS file system permissions:
    • Share permissions:
      1. Add the domain user account for the user who is managing this share, and then click Full Control.

      2. Remove the Everyone group.

      3. If you use the computer startup script method, add the Domain Computers group together with Change and Read permissions.

      4. If you use the logon script method, add the Authenticated Users group together with Change and Read permissions.

    • NTFS permissions:
      1. Add the domain user account for the user who is managing this share, and then click Full Control.
      2. Remove the Everyone group if it is in the list.

        Note If you receive an error message when you remove the Everyone group, click Advanced on the Security tab, and then click to clear the Allow inheritable permissions from parent to propagate to this object check box.
      3. If you use the computer startup script method, grant the Domain Computers group Read & Execute permissions, List Folder Contents permissions, and Read permissions.
      4. If you use the logon script method, grant the Authenticated Users group Read & Execute permissions, List Folder Contents permissions, and Read permissions.
  4. Under the ShareName folder, create a folder that is named "Logs."

    This folder is where the final log files will be collected after the tool runs on the client computers.
  5. To configure the NTFS permissions on the Logs folder, follow these steps.

    Note Do not change the Share permissions in this step.
    1. Add the domain user account for the user who is managing this share, and then click Full Control.
    2. If you use the computer startup script method, give the Domain Computers group Modify permissions, "Read & Execute" permissions, List Folder Contents permissions, Read permissions, and Write permissions.
    3. If you use the logon script method, give the Authenticated Users group Modify permissions, "Read & Execute" permissions, List Folder Contents permissions, Read permissions, and Write permissions.

Deployment methods


Note To run this tool, you must have Administrator permissions or System permissions, regardless of the deployment option that you choose.

How to use the SMS software package

The following example provides step-by-step instructions for using SMS 2003. The steps for using SMS 2.0 resemble these steps.

  1. Extract the Mrt.exe file from the package that is named Windows-KB890830-V1.34-ENU.exe /x.
  2. Create a .bat file to start Mrt.exe and to capture the return code by using ISMIF32.exe.

    The following is an example.
    @echo offStart /wait Mrt.exe /qIf errorlevel 13 goto error13If errorlevel 12 goto error12Goto end:error13Ismif32.exe –f MIFFILE –p MIFNAME –d ”text about error 13”Goto end:error12Ismif32.exe –f MIFFILE –p MIFNAME –d “text about error 12”Goto end:end
    For more information about Ismif32.exe, go to the following article in the Microsoft Knowledge Base:
    186415 Status MIF creator, Ismif32.exe is available
  3. To create a package in the SMS 2003 console, follow these steps:
    1. Open the SMS Administrator Console.
    2. Right-click the Packages node, click
      New, and then click Package.

      The
      Package Properties dialog box is displayed.
    3. On the General tab, name the package.
    4. On the Data Source tab, click to select the This package contains source files check box.
    5. Click Set, and then choose a source directory that contains the tool.
    6. On the Distribution Settings tab, set the Sending priority to High.
    7. On the Reporting tab, click Use these fields for status MIF matching, and then specify a name for the MIF file name field and for the
      Name field.

      Version and Publisher are optional.
    8. Click OK to create the package.
  4. To specify a Distribution Point (DP) to the package, follow these steps:
    1. In the SMS 2003 console, locate the new package under the Packages node.
    2. Expand the package. Right-click Distribution Points, point to New, and then click Distribution Points.
    3. Start the New Distribution Points Wizard. Select an existing Distribution Point.
    4. Click Finish to exit the wizard.
  5. To add the batch file that was previously created to the new package, follow these steps:
    1. Under the new package node, click the Programs node.
    2. Right-click Programs, point to
      New, and then click Program.
    3. Click the General tab, and then enter a valid name.
    4. At the Command line, click
      Browse to select the batch file that you created to start Mrt.exe.
    5. Change Run to
      Hidden. Change After to No action required.
    6. Click the Requirements tab, and then click This program can run only on specified client operating systems.
    7. Click All x86 Windows XP.
    8. Click the Environment tab, click
      Whether a user is logged in the Program can run list. Set the Run mode to Run with administrative rights.
    9. Click OK to close the dialog box.
  6. To create an advertisement to advertise the program to clients, follow these steps:
    1. Right-click the Advertisement node, click New, and then click
      Advertisement.
    2. On the General tab, enter a name for the advertisement. In the Package field, select the package that you previously created. In the Program field, select the program that you previously created. Click Browse, and then click the All System collection or select a collection of computers that only includes Windows Vista and later versions.
    3. On the Schedule tab, leave the default options if you want the program to only run one time. To run the program on a schedule, assign a schedule interval.
    4. Set the Priority to High.
    5. Click OK to create the advertisement.

How to use a Group Policy-based computer startup script

This method requires you to restart the client computer after you set up the script and after you apply the Group Policy setting.

  1. Set up the shares. To do this, follow the steps in the
    Initial setup and configuration section.
  2. Set up the startup script. To do this, follow these steps:
     
    1. In the Active Directory Users and Computers MMC snap-in, right-click the domain name, and then click
      Properties.
    2. Click the Group Policy tab.
    3. Click New to create a new Group Policy Object (GPO), and type MRT Deployment for the name of the policy.
    4. Click the new policy, and then click Edit.
    5. Expand Windows Settings for Computer Configuration, and then click Scripts.
    6. Double-click Logon, and then click Add.

      The Add a Script dialog box is displayed.
    7. In the Script Name box, type
      \\ServerName\ShareName\RunMRT.cmd.
    8. Click OK, and then click Apply.
  3. Restart the client computers that are members of this domain.

How to use a Group Policy-based user logon script

This method requires that the logon user account is a domain account and is a member of the local administrator's group on the client computer.

  1. Set up the shares. To do this, follow the steps in the
    Initial setup and configuration section.
  2. Set up the logon script. To do this, follow these steps:
    1. In the Active Directory Users and Computers MMC snap-in, right-click the domain name, and then click
      Properties.
    2. Click the Group Policy tab.
    3. Click New to create a new GPO, and then type MRT Deployment for the name.
    4. Click the new policy, and then click
      Edit.
    5. Expand Windows Settings for User Configuration, and then click Scripts.
    6. Double-click Logon, and then click Add. The Add a Script dialog box is displayed.
    7. In the Script Name box, type
      \\ServerName\ShareName\RunMRT.cmd.
    8. Click OK, and then click Apply.
  3. Log off and then log on to the client computers.

In this scenario, the script and the tool will run under the context of the logged-on user. If this user does not belong to the local administrators group or does not have sufficient permissions, the tool will not run and will not return the appropriate return code. For more information about how to use startup scripts and logon scripts, go to the following article in the Microsoft Knowledge Base:

Additional information that is relevant to enterprise deployment


How to examine return codes

You can examine the return code of the tool in your deployment logon script or in your deployment startup script to verify the results of execution. See the Code sample section for an example of how to do this.

The following list contains the valid return codes.

0 = No infection found
1 = OS Environment Error
2 = Not running as an Administrator
3 = Not a supported OS
4 = Error Initializing the scanner. (Download a new copy of the tool)
5 = Not used
6 = At least one infection detected. No errors.
7 = At least one infection was detected, but errors were encountered.
8 = At least one infection was detected and removed, but manual steps are required for a complete removal.
9 = At least one infection was detected and removed, but manual steps are required for complete removal and errors were encountered.
10 = At least one infection was detected and removed, but a restart is required for complete removal
11 = At least one infection was detected and removed, but a restart is required for complete removal and errors were encountered
12 = At least one infection was detected and removed, but both manual steps and a restart is required for complete removal.
13 = At least one infection was detected and removed, but a restart is required. No errors were encountered.

How to parse the log file

The Malicious Software Removal Tool writes details about the result of its execution in the %windir%\debug\mrt.log log file.

Notes

  • This log file is available only in English.
  • Starting with version 1.2 of the removal tool (March 2005), this log file uses Unicode text. Before version 1.2, the log file used ANSI text.
  • The log file format has changed with version 1.2, and we recommend that you download and use the latest version of the tool.

    If this log file already exists, the tool appends to the existing file.
  • You can use a command script that resembles the previous example to capture the return code and to collect the files to a network share.
  • Because of the switch from ANSI to Unicode, version 1.2 of the removal tool will copy any ANSI versions of the Mrt.log file in the %windir%\debug folder to Mrt.log.old in the same directory. Version 1.2 also creates a new Unicode version of the Mrt.log file in that same directory. Like the ANSI version, this log file will be appended to each month's release.

The following example is an Mrt.log file from a computer that was infected with the MPnTestFile worm:

Microsoft Windows Malicious Software Removal Tool v5.3, August 2013 (build 5.3.9300.0)Started On Tue Jul 30 23:34:49 2013Quick Scan Results:-------------------Threat Detected: Virus:Win32/MPnTestFile.2004 and Removed! Action: Remove, Result: 0x00000000 regkey://HKLM\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\\v5mpn runkey://HKLM\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\\v5mpn file://c:\temp\mpncleantest.exe SigSeq: 0x00002267735A46E2Results Summary:----------------Found Virus:Win32/MPnTestFile.2004 and Removed!Microsoft Windows Malicious Software Removal Tool Finished On Tue Jul 30 23:35:39 2013Return code: 6 (0x6)  


The following is an example log file where no malicious software is found.

Microsoft Windows Malicious Software Removal Tool v5.3, August 2013 (build 5.3.9300.0)Started On Thu Aug 01 21:15:43 2013Results Summary:----------------No infection found.Microsoft Windows Malicious Software Removal Tool Finished On Thu Aug 01 21:16:28 2013Return code: 0 (0x0) 


The following is a sample log file in which errors are found.


For more information about warnings and errors that are caused by the tool, go to the following article in the Microsoft Knowledge Base:

Microsoft Windows Malicious Software Removal Tool v5.3, August 2013 (build 5.3.9300.0)Started On Fri Aug 02 16:17:49 2013Scan Results:-------------Threat Detected: Virus:Win32/MPTestFile.2004, partially removed. Operation failed. Action: Clean, Result: 0x8007065E. Please use a full antivirus product ! !  file://d:\temp\mpcleantest.7z->mpcleantest.exe SigSeq: 0x00001080D2AE29FC containerfile://d:\temp\mpcleantest.7zResults Summary:----------------Found Virus:Win32/MPTestFile.2004, partially removed.Microsoft Windows Malicious Software Removal Tool Finished On Fri Aug 02 16:18:09 2013Return code: 7 (0x7) 

Known issues


Known issue 1

When you run the tool by using a startup script, error messages that resemble the following error message may be logged in the Mrt.log file:
 

Error: MemScanGetImagePathFromPid(pid: 552) failed.
0x00000005: Access is denied.


Note
The pid number will vary.

This error message occurs when a process is just starting or when a process has been recently stopped. The only effect is that the process that is designated by the pid is not scanned.

Known issue 2

In some rare cases, if an administrator chooses to deploy the MSRT by using the /q quiet switch (also known as silent mode), this may not completely resolve cleaning for a small subset of infections in situations in which additional cleaning is required after a restart. This has been observed only in the removal of certain rootkit variants.

FAQ


Q1. When I test my startup or logon script to deploy the tool, I don't see the log files that are being copied to the network share that I set up. Why?

A1. This is frequently caused by permissions issues. For example, the account that the removal tool was run from does not have Write permission to the share. To troubleshoot this, first make sure that the tool ran by checking the registry key. Alternatively, you can look for the presence of the log file on the client computer. If the tool successfully ran, you can test a simple script and make sure that it can write to the network share when it runs under the same security context in which the removal tool was run.

Q2. How do I verify that the removal tool has run on a client computer?

A2. You can examine the value data for the following registry entry to verify the execution of the tool. You can implement such an examination as part of a startup script or a logon script. This process prevents the tool from running multiple times.

Subkey:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\RemovalTools\MRT
Entry name:
Version

Every time that the tool is run, the tool records a GUID in the registry to indicate that it has been executed. This occurs regardless of the results of the execution. The following table lists the GUID that corresponds to each release.

Q3. How can I disable the infection-reporting component of the tool so that the report is not sent back to Microsoft?

A3. An administrator can choose to disable the infection-reporting component of the tool by adding the following registry key value to computers. If this registry key value is set, the tool will not report infection information back to Microsoft.

Subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MRT
Entry name: \DontReportInfectionInformation
Type: REG_DWORD
Value data: 1

Q4. In the March 2005 release, data in the Mrt.log file appears to have been lost. Why was this data removed, and is there a way for me to retrieve it?

A4. Starting with the March 2005 release, the Mrt.log file is being written as a Unicode file. To make sure of compatibility, when the March 2005 version of the tool is run, if an ANSI version of the file is on the system, the tool will copy the contents of that log to Mrt.log.old in %WINDIR%\debug and create a new Unicode version of Mrt.log. Like the ANSI version, this Unicode version will be appended to with each successive execution of the tool.