Home (All Topics) → Technology → Software → AI-Created Software
The following is AI-generated (aka vibe-coded) software. The software is specific to my needs and my system and may not work for you or your system. Support is limited, but if you report a bug I'll certainly look into it. All code is provided in a zip file for you to review should you choose.
A small Windows tray app that watches programs and restarts them when they crash, hang, or misbehave. Written in C# Windows Forms on .NET Framework 4.8, which ships with Windows 10 and 11, so there is nothing to install: the whole app is a single exe of about 280 KB.
Detection – Crashes and exits are seen the instant they happen. Restart on Crash holds a handle to each monitored process and blocks on WaitForMultipleObjects in one background thread, so waiting costs no CPU. – Hangs: every few seconds Restart on Crash checks the app’s main window with IsHungAppWindow, then confirms with a WM_NULL round trip (SendMessageTimeout) before acting. – “Wait N seconds and check again first” before acting on either kind of detection. – “Has stopped working” dialogs: Windows Error Reporting can keep a crashed process alive behind that dialog. Restart on Crash finds the WerFault.exe that belongs to a monitored app, closes it, and restarts the app. – Resource limits: restart when an app uses more than N MB of memory, or stays above X% CPU for a while.
– Scheduled restarts, for example every weekday at 04:00. – Apps are matched by full path, never just the exe name.
Restarting – Close the process (if still running), then run a command in a working folder. When you pick a running app, the command line and working folder are copied from the live process. – Crash-loop protection: give up after N restarts within M minutes, with a doubling wait between them. – Exit-code rule: optionally treat exit code 0 as a normal close and don’t restart. – Grace periods: after Restart on Crash starts (so a booting PC can settle) and after each restart (globally, or per app). – Responsive apps (schedule, resource limit, Restart now) are asked to close first and only closed by force after 15 seconds.
Running as administrator – “Run as administrator” in Settings registers a Task Scheduler task that starts Restart on Crash with the highest rights at logon (no permission prompt), instead of using the Run key. Running as administrator, it can close hung apps that also do. – Apps that weren’t running as administrator are restarted without it even then (per-app choice: automatic, the same as Restart on Crash, always as administrator, never as administrator). – If you pick a Windows service, Restart on Crash points you to the service’s own Recovery options instead.
The window – A toolbar (Add, Edit, Duplicate, Delete, Undo, Redo, Settings, Show log, Pause, More), the list of applications, and a detail pane for the selected one: what restarts it, the command it runs, its restarts, Restart now and its recent events. – Undo and redo for every change to the list, including Delete, which therefore asks no confirmation. The history lasts until Restart on Crash exits. – The list’s columns fit their contents again whenever the list changes, sort by a click on the heading (a second click reverses), and keep widths you drag. Every window opens where it was last closed, if that place is still on a monitor. – The status bar says how many applications are monitored and shows the result of each action for 8 seconds.
Feedback – The tray icon’s color and mark show the overall status: green with an arrow (all fine), dim red with three dots (checking or restarting), red with “!” (needs attention), gray with two bars (paused). – Notifications on restart; optional webhook (works with Slack and Discord as is) and email alerts. – Log window filtered by application (or Restart on Crash itself), by warnings and errors, and by text. The log file rotates by size, and old files are deleted by count and age. – Pause and resume all monitoring from the tray menu or the toolbar.
Portability – Everything is kept in the working folder (see below). Paths inside Restart on Crash’s own folder are stored relative, so a copy in a Portable Apps folder or on a USB drive keeps working when the drive letter changes. Environment variables work in paths too. – Import and export of the application list.
Run RestartOnCrash.exe. With nothing set up, the main window opens; otherwise Restart on Crash starts in the notification area (unless “Start in the notification area” is off in Settings). Click Add, then either Select a running application… or Select a file…, choose what counts as a crash, and what to do after one.
Right-click a row for Restart now, Resume (after crash-loop protection gave up), and Open file location. Closing the main window keeps Restart on Crash monitoring in the notification area; use Exit in the tray menu (or More in the toolbar) to quit.
The working folder is the one given with --working-folder-path. Blank, it is the exe’s own folder when Restart on Crash’s files are already there or the folder can be written to (a portable copy), and otherwise %APPDATA%\RestartOnCrash. --help shows which one it is on your computer.
| File | What’s in it |
|---|---|
RestartOnCrash.ini |
Preferences ([general], [monitoring], [log], [alerts]), window places ([window], [dialogs], [panels]) and column widths and sorts ([columns]). Each value is read on its own with a fallback, so a mistyped hand edit only resets that value. |
apps.json |
The monitored applications, with a format version. |
state.json |
Restart counters, kept apart so a restart never rewrites the list. |
RestartOnCrash.log |
The log, when “Log events to a file” is on (the file name can be changed in Settings). |
tmp\ |
Temporary files. |
Version 1 kept everything in settings.json. The first start of this version converts it to the files above and renames it settings.json.converted.
Every option takes a value; --help lists them all.
| Option | What it does |
|---|---|
--working-folder-path FOLDER |
The working folder, created if needed. A folder that can’t be created is a mistake (exit code 2). Blank: the default above. |
--selftest TRUE |
Checks the app’s own functions without touching your files, prints one line per check, then “All checks passed.” (exit code 0) or “Some checks FAILED.” (exit code 1). |
--startup TRUE |
Used by the Windows startup entries: skips the tip about the notification area. |
--replace-process-id PID |
Waits up to 10 seconds for that process to exit first; used by “Restart as administrator”. |
--help |
Shows the options and exits. |
A mistake (an unknown option, a missing value, a value that isn’t allowed) prints “Error: …” and “Use –help for usage.” and exits with code 2. Output goes to the console Restart on Crash was started from, or to a message box when there is none. Startup entries written by version 1 pass a bare --startup, which still works and is rewritten on the next start.
| Key | Where | What it does |
|---|---|---|
| Ctrl+N | Main window | Add an application. |
| Enter | The list | Edit the selected application (or double-click it). |
| Ctrl+D | Main window | Duplicate the selected application. |
| Del | The list | Delete the selected applications. |
| Space | The list | Turn the selected applications on or off. |
| Ctrl+Z | Main window | Undo the last change to the list. |
| Ctrl+Y or Ctrl+Shift+Z | Main window | Redo. |
| Ctrl+C | Log | Copy the selected events, or all shown. |
| Ctrl+A | Text fields | Select all. Right-click a field for Cut, Copy, Paste and Select all. |
| Esc | Any window | Close it (a dialog without saving). |
On Windows, run the build script from the repository folder:
.\build.ps1 -Output "D:\PortableApps\RestartOnCrash\RestartOnCrash.exe"
or build.cmd with the same arguments if PowerShell scripts are blocked on your PC. The script writes RestartOnCrash.exe and RestartOnCrash.exe.config to the path you give.
| Parameter | Default | What it does |
|---|---|---|
-Output |
.\dist\RestartOnCrash.exe |
Where to write the exe. A folder (existing, or ending in \) gets RestartOnCrash.exe inside it. |
-Configuration |
Release |
Release or Debug. |
-Compiler |
Auto |
DotNet uses the .NET SDK and runs the unit tests.Csc uses the C# compiler built into Windows, so nothing needs installing (no tests). Auto uses the SDK if it’s installed. |
-Version |
from the project file | Version stamped into the exe, such as 1.2.0. |
-SkipTests |
Don’t run the unit tests. | |
-Force |
Overwrite an existing exe without asking. |
Run Get-Help .\build.ps1 -Detailed for the full help.
Without the script, the .NET SDK 8 or later builds it on any OS:
dotnet build RestartOnCrash.sln -c Release
The code is kept to C# 5 so the compiler that ships with Windows can build it. Visual Studio 2019 or later also opens the solution. CI builds both ways on windows-latest, runs every test and the self-test, and attaches the exe to each run.
dotnet test tests/RestartOnCrash.Tests runs the core tests (settings files, the command line, crash-loop protection, schedules, undo, the log) on any OS: 93 tests.dotnet test tests/RestartOnCrash.UiTests runs the window tests on Windows: every color is from the palette, windows and columns remember their places and widths, dialogs keep their margins, closing the main window lets go of it, and the exe’s --selftest TRUE, --help and command-line mistakes: 20 tests.RestartOnCrash.exe --selftest TRUE checks a built exe.xunit.console.exe; RESTARTONCRASH_TEST_SCALE=1.5 draws the windows as at 150% scaling, since Xvfb always reports 100%. The running-applications window test needs Windows.
apps.damaged-<date and time>.json: the file wasn’t valid JSON (often a hand edit). Restart on Crash starts with an empty list and leaves the damaged copy beside it to fix or delete.--working-folder-path.[window] or [dialogs] in RestartOnCrash.ini; places on a monitor that is no longer there are already ignored.
| Path | What’s there |
|---|---|
src/RestartOnCrash/Core |
Settings files (INI, JSON with damaged and locked handling), the working folder, command-line options, the self-test, undo history, crash-loop guard, schedules, command lines, rotating logger. No Windows dependencies; unit tested. |
src/RestartOnCrash/Monitoring |
The monitor thread and the Win32 process inspection it uses. |
src/RestartOnCrash/Platform |
Running as administrator, startup registration (Run key or Task Scheduler), console output, service detection, password encryption. |
src/RestartOnCrash/Alerts |
Webhook and email alerts. |
src/RestartOnCrash/UI |
The tray icon and windows, built in code (no designer files): Theme.cs (palette, fonts, scaling), Widgets.cs and Ui.cs (controls and layout), TableView.cs, Places.cs. Windows are created when opened and disposed when closed. |
tests/RestartOnCrash.Tests |
xUnit tests for the Core code (net8.0). |
tests/RestartOnCrash.UiTests |
xUnit tests for the windows and the exe (net48). |


Leave a Reply