lastexecrecord Kazushi Kamegawa
winget install --id=kkamegawa.lastexecrecord -e LastExecRecord is a simple launcher
winget install --id=kkamegawa.lastexecrecord -e LastExecRecord is a simple launcher
Lightweight Windows console application. Every time it is invoked, it runs the commands registered in the JSON config once, in order, and skips commands when they should not run based on:
It avoids external libraries (Win32 API + STL only) and focuses on safe operation via config file locking and atomic updates.
lastexecuterecord.exe (no arguments needed)%USERPROFILE%\.lastexecrecord\config.jsonenabled: true and customize exe / args for your commandslastexecuterecord.exe again to execute your commandsBy default, the app reads %USERPROFILE%\.lastexecrecord\config.json.
If this file doesn't exist, a minimal sample config is created automatically (with commands disabled by default for safety).
winget install kkamegawa.lastexecrecord
After installation, you can run lastexecuterecord.exe from your terminal.
lastexecuterecord.exe: Run with default config (auto-creates sample if missing)lastexecuterecord.exe --config : Specify a custom config JSON pathlastexecuterecord.exe --dry-run: Do not execute; only show decisionslastexecuterecord.exe --verbose: Verbose logs (including skip reasons)All options can be combined, for example: lastexecuterecord.exe --config myconfig.json --dry-run --verbose
To register lastexecuterecord.exe as a Windows Terminal profile and continue running PowerShell or Command Prompt after execution, add the following profile to your Windows Terminal settings.json:
{
"profiles": {
"list": [
{
"name": "lastexecrecord + PowerShell",
"commandline": "cmd.exe /c lastexecuterecord.exe && pwsh.exe",
"icon": "ms-appx:///ProfileIcons/PowerShell.png"
},
{
"name": "lastexecrecord + Command Prompt",
"commandline": "cmd.exe /c lastexecuterecord.exe && cmd.exe",
"icon": "ms-appx:///ProfileIcons/CommandPrompt.png"
}
]
}
}
&& executes the next shell only if lastexecuterecord.exe exits successfully; instead of && if you want to continue regardless of exit code: cmd.exe /c lastexecuterecord.exe ; pwsh.exeTo edit settings.json, open Windows Terminal and press Ctrl + , or click the Settings icon.
Example: lastexecuterecord.sample.json
version (number, optional): Default is 1networkOption (number, optional): Control execution based on network status. Default is 2
0: Execute only when internet is connected (not on metered connections)1: Execute even on metered connections (internet connection required)2: Always execute (ignore network status)defaults.minIntervalSeconds (number, optional): Default minimum interval for commandsdefaults.timeoutSeconds (number, optional): Default timeout for commandsdefaults.installerWaitBehavior (string or number, optional): Default behavior when installer is running. Default is "wait"
"wait" or 0: Wait for installer to finish before executing"skip" or 1: Skip command if installer is runningdefaults.installerWaitSeconds (number, optional): Wait time in seconds between installer checks. Default is 30defaults.installerMaxRetries (number, optional): Maximum number of retries when waiting. Default is 10commands (array, required): List of commands to run (processed from top to bottom)name (string, required): Display name / identifierenabled (bool, optional): Default is trueexe (string, required): Executable path (not a shell string; use exe + args)args (array of string, optional): ArgumentsworkingDirectory (string, optional)minIntervalSeconds (number, optional): Defaults to defaults.minIntervalSecondstimeoutSeconds (number, optional): Defaults to defaults.timeoutSecondsinstallerWaitBehavior (string or number, optional): Behavior when installer is running. Defaults to defaults.installerWaitBehaviorinstallerWaitSeconds (number, optional): Wait time between checks. Defaults to defaults.installerWaitSecondsinstallerMaxRetries (number, optional): Maximum retries. Defaults to defaults.installerMaxRetrieslastRunUtc (string, optional): Example 2026-01-02T12:34:56Z (seconds precision)lastExitCode (number, optional): Previous exit code{
"version": 1,
"defaults": {
"minIntervalSeconds": 64800,
"timeoutSeconds": 0
},
"commands": [
{
"name": "winget",
"enabled": true,
"exe": "c:\\windows\\system32\\sudo.exe",
"args": [
"winget",
"upgrade",
"--all",
"--accept-package-agreements",
"--silent"
]
}
]
}
exe + args[] and does not assume shell execution like cmd.exe /c (helps reduce injection risk)..lock file.exe or args in the config file, as this may lead to command injection vulnerabilities.If a Windows installer process (such as msiexec.exe) is running in the background, some installers launched by this program may fail. To handle this scenario, the application can:
This behavior is controlled by the installerWaitBehavior configuration field (either globally in defaults or per-command).
Before executing each command, the application checks if any of the following installer processes are running:
msiexec.exe (Windows Installer)setup.exe, install.exe, setupapi.exe, msiinstall.exe, windows installer.exeIf an installer is detected and installerWaitBehavior is "wait" (default):
installerWaitSeconds seconds (default: 30 seconds)installerMaxRetries times (default: 10 retries)If an installer is detected and installerWaitBehavior is "skip":
{
"defaults": {
"installerWaitBehavior": "wait",
"installerWaitSeconds": 30,
"installerMaxRetries": 10
},
"commands": [
{
"name": "system update",
"exe": "winget.exe",
"args": ["upgrade", "--all"],
"installerWaitBehavior": "wait"
}
]
}
This project uses Visual Studio 2022/2025 or MSBuild.
Visual Studio:
Open src\lastexecrecord.sln in Visual Studio
Build -> Build Solution
MSBuild (command line):
msbuild src\lastexecrecord.sln /p:Configuration=Release /p:Platform=x64
For other platforms:
REM Debug build for x64
msbuild src\lastexecrecord.sln /p:Configuration=Debug /p:Platform=x64
REM Release build for ARM64
msbuild src\lastexecrecord.sln /p:Configuration=Release /p:Platform=ARM64
Tests have been migrated to Microsoft Unit Testing Framework for C++ (MSTest).
Run tests in Visual Studio:
src\lastexecrecord.sln in Visual StudioSee src/lastexecuterecord.mstest/ for the test project and src/docs/MSTEST-MIGRATION.md for migration details.