The error message "Failed to execute script mspm-source" typically appears on Windows startup and is strongly associated with malware residue or an improperly removed PUP (Potentially Unwanted Program).
While the "Failed to execute script" dialog is a common PyInstaller error, the specific "mspm-source" file is often identified by security researchers as a script used by crypto-miners or adware that attempts to re-execute every time you log in. The error occurs because your antivirus software has likely deleted the malicious file, but the "startup trigger" (registry key or scheduled task) remains. 🛠️ Step-by-Step Fix (Full Write-Up) 1. Remove the Startup Trigger using Autoruns
This is the most effective way to stop the error by deleting the link that tells Windows to run the missing script. Download the official Microsoft Autoruns tool. Extract the ZIP and run Autoruns64.exe as Administrator. Wait for the "Ready" status at the bottom. In the Filter/Search box at the top, type mspm-source.
If you see any entries highlighted in yellow (meaning "File Not Found") or specifically mentioning mspm-source, right-click them and select Delete. Restart your computer to verify the error is gone. 2. Scan for Deep Malware Residue failed to execute script mspm-source
Even if the script is missing, the installer that put it there might still be active in your system's temporary folders.
Run a full scan with the Microsoft Safety Scanner to ensure no other malicious processes are running.
Clear your Temp folder: Press Win + R, type %temp%, and delete all files in that folder. 3. Check Task Scheduler The error message "Failed to execute script mspm-source"
Sometimes the script is triggered by a timed task rather than a login entry. Open the Start Menu and search for Task Scheduler.
Look through the "Task Scheduler Library" for any unusual names like mspm, update-sys, or source-runner. If found, right-click and Disable or Delete them. 💡 Why did this happen?
This is the most common cause. You may have uninstalled McAfee or another antivirus tool, but the uninstaller failed to remove all traces. A leftover registry key or a shortcut in the Windows Startup folder still points to mspm-source. If you need a 32-bit executable, use a
Ensure you’re building on the same architecture as the target machine. Check Python bitness:
python -c "import struct; print(struct.calcsize('P') * 8)"
If you need a 32-bit executable, use a 32-bit Python interpreter to run PyInstaller.
There are four primary reasons why this error manifests on a Windows machine:
| Field | Details |
|-------|---------|
| Error | failed to execute script mspm-source |
| Type | Runtime / packaging error (PyInstaller, cx_Freeze, or similar) |
| Observed On | Executing the compiled executable mspm-source.exe (or binary) |
| Environment | Windows / Linux (usually missing dependencies or path issues) |