A Windows service tool that automatically monitors Battle.net processes and cleans up background Agent processes upon exit.
- Features
- Problem Background
- Quick Start
- File Description
- Configuration
- Service Management
- Manual Installation
- Logging
- Troubleshooting
- System Requirements
- Disclaimer
- ๐ฏ Smart Monitoring: Automatically detects the status of the Battle.net main process
- ๐งน Automatic Cleanup: Cleans up background Agent processes when Battle.net exits
- ๐ง Service Operation: Runs as a Windows service, no user intervention required
- โก Low Resource Usage: Checks every 10 minutes, minimal system resource consumption
- ๐ Detailed Logging: Comprehensive operation logs and error records
- โ๏ธ Highly Configurable: Customize monitoring parameters via configuration file
- ๐ฆ Portable Deployment: All files use relative paths and can be placed anywhere
After the Battle.net client exits, related Agent.exe processes sometimes continue running in the background, causing:
- High CPU usage by WmiPrvSE.exe process
- System resource waste
- Manual process termination required
This tool specifically addresses this issue by automatically monitoring and cleaning up these residual processes when Battle.net exits.
# Execute in the project directory
.\Download-NSSM.ps1This script automatically downloads and configures NSSM (service manager).
# Install service with administrator privileges
.\Install-BattleNetAgentKillerService.ps1# Check service status
.\Manage-BattleNetAgentKillerService.ps1 -Action statusIf you see the service status as "Running", the installation was successful!
BattleNetAgentKiller/
โโโ ๐ BattleNetAgentKiller.ps1 # Main monitoring script
โโโ โ๏ธ BattleNetAgentKiller-config.ini # Configuration file
โโโ ๐ BattleNetAgentKiller.log # Runtime log
โโโ ๐ง nssm.exe # Service manager
โโโ ๐ฅ Download-NSSM.ps1 # NSSM download script
โโโ ๐ ๏ธ Install-BattleNetAgentKillerService.ps1 # Service installation script
โโโ ๐๏ธ Manage-BattleNetAgentKillerService.ps1 # Service management script
Edit the BattleNetAgentKiller-config.ini file to customize behavior:
[Settings]
; Battle.net main process name (without .exe)
BattleNetProcessName=Battle.net
; Battle.net main process path pattern (using wildcards)
BattleNetExePattern=*\Battle.net.exe
; Agent process name (without .exe)
AgentProcessName=Agent
; Agent process path pattern (using wildcards)
AgentExePattern=*\Battle.net\Agent\*\Agent.exe
; Check interval (seconds) - Default 10 minutes
CheckInterval=600
; Enable verbose logging (true/false)
VerboseLogging=true
[Logging]
; Log file path (relative path)
LogPath=BattleNetAgentKiller.log
; Enable log rotation (true/false)
EnableLogRotation=true
; Maximum single log file size (MB)
MaxLogSizeMB=5
; Number of log files to retain
MaxLogFiles=3- Check Interval: Recommended to keep at 600 seconds (10 minutes) to balance real-time performance and resource usage
- Verbose Logging: Set to true for debugging, false for normal use to reduce log volume
- Path Patterns: Use wildcard
*to match different version paths
.\Manage-BattleNetAgentKillerService.ps1 -Action status.\Manage-BattleNetAgentKillerService.ps1 -Action start.\Manage-BattleNetAgentKillerService.ps1 -Action stop.\Manage-BattleNetAgentKillerService.ps1 -Action restart.\Manage-BattleNetAgentKillerService.ps1 -Action removeIf automatic installation fails, you can install the service manually:
- Open Command Prompt as Administrator
- Navigate to the project directory
- Execute the following commands:
nssm install BattleNetAgentKiller "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
nssm set BattleNetAgentKiller AppDirectory "Full path to current project"
nssm set BattleNetAgentKiller AppParameters "-ExecutionPolicy Bypass -WindowStyle Hidden -File BattleNetAgentKiller.ps1"
nssm set BattleNetAgentKiller DisplayName "BattleNet Agent Killer"
nssm set BattleNetAgentKiller Description "Monitors Battle.net processes and automatically cleans up Agent processes upon exit"
nssm set BattleNetAgentKiller Start SERVICE_AUTO_START
nssm start BattleNetAgentKillerThe tool provides multi-level logging:
- File:
BattleNetAgentKiller.log - Content: Main program runtime logs, including detection and cleanup records
- Directory:
logs\ - Files:
service.log- Service standard outputservice-error.log- Service error output
[2024-01-15 14:30:01] [INFO] === Detection Cycle #5 (2024-01-15 14:30:01) ===
[2024-01-15 14:30:01] [INFO] Battle.net process status: Running, Process count: 1
[2024-01-15 14:30:01] [INFO] Battle.net is running, skipping cleanup
Possible Causes:
- Installation script not run with administrator privileges
- Incorrect configuration file path
- NSSM download incomplete
Solutions:
- Right-click the installation script and select "Run as administrator"
- Check the
logs\service-error.logfile - Re-run
.\Download-NSSM.ps1
Possible Causes:
- Process path doesn't match configuration
- Insufficient permissions
- Process is being used by another program
Solutions:
- Check path patterns in the configuration file
- Confirm the service is running under the SYSTEM account
- Check detailed logs for specific errors
Solutions:
- Manually visit NSSM Official Website
- Download nssm 2.24
- Place the appropriate architecture nssm.exe in the project directory
# Stop and remove service
.\Manage-BattleNetAgentKillerService.ps1 -Action remove
# Manual cleanup (if needed)
Stop-Process -Name "powershell" -ErrorAction SilentlyContinue- Operating System: Windows 7 / 8 / 10 / 11 / Server 2008+
- PowerShell: Version 5.0 or higher
- Permissions: Administrator privileges (required only for installation)
- Space: Approximately 10MB available space
- Service Startup: Monitoring service automatically runs at system startup
- Periodic Checks: Checks Battle.net process status every 10 minutes
- Smart Decision Making:
- If Battle.net is running โ Wait for next check
- If Battle.net has exited โ Clean up all matching Agent processes
- Continuous Execution: Persistent monitoring ensures no cleanup opportunities are missed
A: This tool only terminates Battle.net-related Agent processes and does not affect other system processes. The code is open source and can be reviewed.
A: No. The tool only cleans up processes after Battle.net exits and does not interfere with normal Battle.net operation.
A: Check the BattleNetAgentKiller.log file to see records of each detection and cleanup.
A: Yes. Modify the CheckInterval parameter in the configuration file (unit: seconds).
- โ Initial version release
- โ Basic monitoring and cleanup functionality
- โ Service deployment
- โ Complete configuration system
If you encounter issues:
- First check the log files for detailed information
- Verify configuration file parameters are correct
- Try restarting the service:
.\Manage-BattleNetAgentKillerService.ps1 -Action restart
This tool is for learning and technical exchange purposes only. Users shall bear any risks and responsibilities arising from the use of this tool. The tool author is not responsible for any losses or damages caused by using this tool.
Enjoy a clean gaming environment! ๐ฎ