Trojan:MSIL/Heracles Keeps Coming Back After Every Restart

Published by Nyau Wai Hoe - Updated on

Windows Security normally removes a threat once and that’s the end of it, but with “Trojan:MSIL/Heracles.A!MTB” (or Heracles.ARA!MTB or Heracles.MK!MTB), the alert comes back every time you start or sign in to your PC, often on a new randomly named .dll file in your Temp folder, even after full and offline scans come back clean. This guide will show you how to find what keeps bringing it back and remove it for good on Windows 11 or 10.

Also see: Trojan:PowerShell/Boxter Keeps Coming Back in Windows Security

Trojan:MSIL/Heracles Keeps Coming Back After Every Restart

Why does Heracles keep coming back?

Heracles is a broad name Microsoft Defender gives to malicious programs written in .NET (that’s the “MSIL” part). Microsoft rates it as severe but publishes little about each variant, so assume the worst.

What people usually see:

  • A detection at every startup on a file like C:\Users\<name>\AppData\Local\Temp\tepxtzja\tepxtzja.dll, with a different random name each time. When you go to the folder, the file is already gone, since Defender removed it.
  • Sometimes a PowerShell or Command Prompt window flashing up for a moment when you sign in.
  • With the ARA variant, the affected item is amsi: followed by MSBuild.exe in the Windows\Microsoft.NET\Framework\v4.0.30319 folder.

The .dll isn’t the real problem. Something left behind on your PC creates a new one at every start, and in almost every case that’s a scheduled task that runs a hidden PowerShell command. Defender catches the file each time, but not the task that makes it, which is why scans keep coming back clean.

It’s often linked to a cracked game, a “free” game installer or port, or a game mod. Some people also had their Discord, email or other accounts taken over soon after.

Please note that MSBuild.exe and PowerShell are real Windows files that the malware only borrows, so don’t delete them. Also, don’t choose Allow on the detection, even if you think it’s a false positive. Once you’ve downloaded Autoruns and Microsoft Safety Scanner (both below), keep the PC offline while you clean up.

Linked issue: MSBuild.exe Virus Keeps Connecting to Unknown Websites

Find and delete the scheduled task that brings it back

This is what stops the alerts for most people. The task often has a name made to look like part of Windows or a game, such as “SystemCacheMaintenance“, “NetworkDiagnosticService” or “GameUpdaterDLC“, and runs a script hidden in a folder under C:\ProgramData or AppData. Here’s how to find it:

  1. Press Win + R, type taskschd.msc and press Enter to open Task Scheduler.
  2. Click Task Scheduler Library on the left.
  3. Look through the tasks listed there (not the ones inside the Microsoft folder; OneDrive and Edge update tasks are normal there, as long as they don’t run PowerShell). Click each one you don’t recognize and open the Actions tab at the bottom.Suspicious PowerShell task in Task Scheduler Library Windows 11
  4. A malicious task usually runs powershell.exe with options like -WindowStyle Hidden or -ExecutionPolicy Bypass, or a .ps1 or .vbs file in ProgramData or AppData. Note down the path of the file it runs.
  5. With the task selected, click Delete under Selected Item on the right (or right-click the task and select Delete), then confirm.Delete scheduled task Task Scheduler Windows 11
  6. Go to the folder you noted in File Explorer and delete it as well.

If there were several such tasks, delete them all. Then restart the PC (not a shutdown) and see if the alert still shows up.

Not sure which task it is? Check what created the file

Windows Security logs every detection in Event Viewer, including which program dropped the file. Here’s how to check it:

  1. Press Win + R, type eventvwr.msc and press Enter.
  2. Go to Applications and Services Logs > Microsoft > Windows > Windows Defender > Operational.Windows Defender Operational log in Event Viewer Windows 11
  3. Look for events with ID 1116 (malware detected) and read the details below.

If the process shown is powershell.exe, you know you’re looking for a task that runs PowerShell.

Use Autoruns to see everything that starts by itself

If Task Scheduler doesn’t show anything suspicious, try Autoruns, Microsoft’s own free tool that lists every scheduled task, startup entry and service in one place. Here’s how to use it:

  1. Go to https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns and download Autoruns.
  2. Extract the zip file, right-click Autoruns64, select Run as administrator and click Agree on the license.
  3. Click Options and make sure Hide Microsoft Entries is checked, which hides most of Windows’ own entries.
  4. Open the Scheduled Tasks tab, then look at the Logon and Services tabs too.Autoruns Scheduled Tasks tab Windows 11
  5. Uncheck any entry that runs PowerShell or a file in a randomly named folder, instead of deleting it right away. These still show Microsoft as the publisher, since powershell.exe is Microsoft’s own file, so go by the task’s name and Image Path, not the Publisher column.
  6. Restart the PC. If the alert doesn’t come back, open Autoruns again, right-click those entries and select Delete.

Run a Microsoft Defender Offline scan

Once the task is gone, run an offline scan to clean up anything else the malware left. It runs from outside Windows, so it can catch files that hide while Windows is running. Save your work first, as the PC will restart.

  1. Open Windows Security and go to Virus & threat protection.
  2. Under Current threats, click Scan options.
  3. Select “Microsoft Defender Antivirus (offline scan)” and click Scan now.Microsoft Defender Offline scan Windows 11

The scan takes about 15 minutes. Check Protection history in Windows Security when the PC is back.

Get a second opinion with another scanner

A second scanner can find pieces Defender misses. Microsoft Safety Scanner is the easy choice, as it’s from Microsoft and doesn’t need to be installed:

  1. Go to https://learn.microsoft.com/en-us/defender-endpoint/safety-scanner-download and download the 64-bit version.
  2. Run msert.exe, accept the license terms and click Next twice.
  3. Select Full scan and click Next.Microsoft Safety Scanner full scan Windows 11

It removes what it finds. The download expires after 10 days. ESET Online Scanner and the free version of Malwarebytes are also good options for a second check.

If the alert still comes back, volunteers on malware removal forums can help. You run FRST (Farbar Recovery Scan Tool), post its log, and they write a fix made for your PC. That’s what finally cleared it for a few people.

Change your passwords from another device

Even after the alerts stop, assume your saved passwords and browser sessions were stolen. A stolen session can let someone stay signed in to your account even with two-factor authentication on.

  1. On your phone or another computer you trust, change the password of your email account first.
  2. Next, change the passwords for your bank and payment accounts, then Discord, Steam, social media and the rest.
  3. Turn on two-factor authentication where you can.
  4. Sign out of all other sessions in each account’s security settings, so the stolen sessions stop working.

Related concern: Trojan.PavinLoader Keeps Coming Back After Malwarebytes Removes It

Reset Windows if it still comes back

If the alert is still there after all this, or your accounts were already being taken over, the surest way is to wipe the PC. Many people with this detection ended up doing it.

Back up only your personal files (documents, photos, saves), and leave out the game, installer or mod you think it came from. Then:

  1. Open Settings and go to System > Recovery.
  2. Next to Reset this PC, click Reset PC.Reset PC in Recovery settings Windows 11
  3. Choose Remove everything, then Cloud download (reconnect the PC to the internet for this), and follow the rest of the steps.

For more details, see How to Reset Windows 11/10 to Factory Default. Only sign back in to your accounts once the reset is done.


Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 15 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.