A robust Windows console application for launching games with advanced monitoring, crash recovery, and watchdog functionality. Built with C# and .NET 10.0 with additional PowerShell helper scripts for launch orchestration, cleanup, and diagnostics.
- Game Launch Management: Launch Windows games with customizable profiles
- Process Monitoring: Real-time monitoring of game processes with hang detection
- Automatic Recovery: Configurable restart policies for crashed or hung games
- Comprehensive Logging: Detailed logging of launch attempts, process events, and diagnostics
- Environment Variable Support: Custom environment variables per game profile
- PowerShell Integration: Helper scripts for launch, cleanup, and diagnostics collection
The application follows a service-oriented architecture:
- Program.cs: Main entry point and orchestration
- LauncherService: Handles game process creation and startup
- WatchdogService: Monitors processes and manages restart logic
- ProcessMonitorService: Tracks process state and detects hangs
- LogService: Centralized logging functionality
- ProfileService: Loads and validates game profiles
- Operating System: Windows 10 or later
- .NET Runtime: .NET 10.0 Runtime
- Permissions: Administrator privileges may be required for some games
- Clone or download the repository
- Build the project using Visual Studio or the .NET CLI:
dotnet build
Run the launcher with a game profile:
WindowsGameLauncher.exe [profile_path]If no profile path is provided, it defaults to gameProfile.json in the same directory as the executable.
- Load and validate a launch profile
- Start the target executable with the configured working directory, arguments, and environment variables
- Monitor the process until it exits or exceeds the configured hang timeout
- Capture periodic process snapshots while the process is running
- Log normal exits, abnormal exits, and timeouts
- Optionally restart the process if configured to do so
Create a gameProfile.json file with your game configuration:
{
"gameName": "Your Game Name",
"exePath": "C:/Path/To/Game.exe",
"workingDirectory": "C:/Path/To/Game",
"arguments": "",
"maxHangTimeSeconds": 300,
"maxRestarts": 3,
"restartDelaySeconds": 5,
"shouldRestartOnCrash": true,
"environmentVariables": {
"EXAMPLE_VAR": "value"
}
}gameName: Display name for the gameexePath: Full path to the game executableworkingDirectory: Working directory for the game processarguments: Command-line arguments to pass to the gamemaxHangTimeSeconds: Maximum time (in seconds) before considering the process hungmaxRestarts: Maximum number of restart attemptsrestartDelaySeconds: Delay between restart attemptsshouldRestartOnCrash: Whether to restart on crashes or abnormal exitsenvironmentVariables: Dictionary of environment variables to set
The project includes PowerShell scripts in the scripts/ directory:
.\scripts\launch_game.ps1 -ProfilePath "path/to/profile.json" -ProjectRoot "."Automatically archives old log files and cleans up temporary files.
Collects system information, running processes, and event logs for troubleshooting.
- Open
WindowsGameLauncher.sln - Select Debug or Release configuration
- Build → Build Solution
# Build in Debug mode
dotnet build
# Build in Release mode
dotnet build --configuration Release
# Publish as self-contained executable
dotnet publish --configuration Release --self-contained true --runtime win-x64Logs are written to the logs/ directory with the format log_YYYYMMDD.txt. The application logs:
- Launch attempts and results
- Process events (start, exit, hangs)
- Game output and error streams
- Recovery actions and restart attempts
- "Executable not found": Ensure the
exePathin your profile points to a valid executable - Permission denied: Some games require administrator privileges
- Process hangs not detected: Adjust
maxHangTimeSecondsbased on your game's behavior
Run the diagnostics script to collect system information:
.\scripts\collect_diagnostics.ps1This creates a diagnostics file in logs/diagnostics/ with:
- Running processes
- System information
- Recent event log entries
- Environment variables
This project is licensed under the MIT License - see the LICENSE file for details.