SkillAgentSearch skills...

RunExit

A simple 16-bit Windows utility intended to run a single application and immediately exit Windows after that application quits.

Install / Use

/learn @andshrew/RunExit
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

RunExit

RUNEXIT.EXE is a simple 16-bit Windows utility intended to run a single application and immediately exit Windows after that application quits.

It is ideal for use with emulation systems like DOSBox, where you may want to be able to launch a Windows game (or application) and have it automatically start and then exit once the program has finished.

This has been tested with DOSBox 0.74 and DOSBox-X 2024.03.01 using their native DOS implementations, with Windows 3.1.

Origins

This is a fork of version 1.1 of the application (26th May 2013), written by Steven Henk Don.

https://www.shdon.com/software/tools

https://www.shdon.com/files/runexit.zip

This tag contains the original source code of version 1.1 along with a build of the release. The original source is redistributed with the permission of Steven, and subsequent changes within this fork of the code are released under the MIT License.

Table of Contents

Changes from original version

  • Support for identifying when an application switches execution to another process
    RunExit v1.5 and prior would launch an application and then exit Windows once the system reported that the application was no longer loaded.
    There are some applications that subsequently launch another executable, or perform some other action, which results in the originally launched application being detected as longer being loaded; and so RunExit would attempt exit Windows while that application was still actually running.
    Now when the launched application is reported as no longer being loaded, RunExit will iterate through all currently loaded modules to try and find any related modules that are loaded. If a related module is found then it will only exit Windows once all related modules are unloaded.
    This change should fix compatibility with a majority of such applications.
    See Related Module Matching for additional information.
    To disable this feature use parameter /legacy which reverts application exit behaviour to that of v1.5 (and prior), see Disabling Related Module Matching.

  • The trailing \ is removed from the application directory path
    When parsing the application path to determine what the working directory should be set to, the original version would include the trailing \ within the path and pass that through to ShellExecute.
    eg. C:\MPS\GPM\GPM.EXE would set the working directory as C:\MPS\GPM\
    This version sets the working directory without the trailing \:
    C:\MPS\GPM\GPM.EXE now sets the working directory as C:\MPS\GPM You can override the path of the working directory if the application needs to run in a different directory than the executable by passing a /pwd=[path] parameter to RUNEXIT.EXE, before the application path.

  • Exit Windows will keep retrying for ~10 seconds
    Depending on the application being launched, sometimes the exit from Windows after the application had finished would intermittently (but consistently) fail.
    This version of the application will keep trying to exit Windows for ~10 seconds after the application has finished. If it still cannot exit Windows then it will prompt the user that it has failed.

  • ShellExecute error codes are now displayed
    If ShellExecute fails to run the application, then a message box is displayed along with the error code. A list of error codes are here.

  • Application startup behavior can be changed
    The default application startup SW_SHOWNORMAL can be overridden to a different value by passing a /show=[number] parameter to RUNEXIT.EXE, before the application path. This allows starting the application minimized, maximized, or in the "background" (not activated). A list of valid values are here.

  • Optional delay before launching the application
    A delay (in seconds) can be specified before launching the application by passing a /delay=[seconds] parameter to RUNEXIT.EXE, before the application path. This is useful if you need to ensure Windows and its drivers are fully initialized before starting the application. The delay can be a maximum of 30 seconds.
    Example: /delay=5 will wait 5 seconds before launching the application.

  • Optional log file creation
    To assist with troubleshooting, a log file can be generated by passing a /log parameter to RUNEXIT.EXE before the application path. This will create runexit.log at the root of the default drive (eg. C:\runexit.log). If the file already exists then it is overwritten. In order to capture the most amount of detail in the log file, this should be the first parameter that is supplied to RUNEXIT.EXE.
    Example: win C:\runexit\runexit.exe /log c:\mps\gpm\gpm.exe

Usage

Download RUNEXIT.EXE from the releases page and copy it to your system; these examples will assume that you save it to C:\RUNEXIT\RUNEXIT.EXE and that win is in your PATH.

Basic Usage

win C:\runexit\runexit.exe [optional runexit parameters] [path to application] [optional application parameters]

Command Line Parameters

| Parameter | Description | Example | |------------------|-------------|---------| | /delay=[seconds] | Delay launching the application by up to 30 seconds | Example | | /legacy | Disable related module matching, launched application exit behaviour restored to that of v1.5 and prior<br>See Related Module Matching and Disabling Related Module Matching | Example | /log | Create runexit.log at the root of the default drive (eg. c:\runexit.log)<br>This should be the first parameter set to capture all output | Example | /matchall | Set the related module matching behaviour to match any loaded module<br>See Related Module Matching and Match Any Loaded Module | Example | /module=[name] | Set the related module matching behaviour to only match a specific module<br>See Related Module Matching and Match a Specific Module Name | Example | /pwd=[path] | Set the working directory for the application | Example | /show=[number] | Set the initial state of the application window (ie. minimized, maximized)<br>See valid nCmdShow values | Example |

Example 1

Run application C:\MPS\GPM\GPM.EXE with no additional parameters.

win C:\runexit\runexit.exe c:\mps\gpm\gpm.exe

Example 2

Run application C:\GAMES\MYGAME\GAME.EXE with parameter /cheatmode

win C:\runexit\runexit.exe c:\games\mygame\game.exe /cheatmode

Example 3

Run application C:\WEP\JEZZBALL.EXE in a maximized window.

win C:\runexit\runexit.exe /show=3 c:\wep\jezzball.exe

Example 4

Run application C:\CASTLE\CASTLE.EXE with a 5 second delay before launch.

win C:\runexit\runexit.exe /delay=5 c:\castle\castle.exe

Example 5

Run application D:\WIN31\RBJR.EXE with the working directory as D:\RESOURCE.

win C:\runexit\runexit.exe /pwd=D:\resource D:\win31\rbjr.EXE

Example 6

Run application C:\MPS\GPM\GPM.EXE with parameter /log

win C:\runexit\runexit.exe /log c:\mps\gpm\gpm.exe

Example 7

DOSBox AUTOEXEC to run application C:\MPS\GPM\GPM.EXE with no additional parameters.
On running DOSBox this would load Windows and run the application. Once the application is closed Windows will then exit, and DOSBox will close.

mount C "data/drive_c"
PATH C:\WINDOWS;
SET TEMP=C:\WINDOWS\TEMP
C:
win C:\runexit\runexit.exe c:\mps\gpm\gpm.exe
exit

Related Module Matching

When the launched application is reported as being unloaded, RunExit will attempt to find any related modules that may still be running before exiting Windows. If one is found then it is assumed that the launched application is in fact still running, and RunExit will continue to wait until all related modules have ended before finally exiting Windows.

Modules are matched based on their path, so for example if you launch C:\SC2K4WIN\SC2000W.EXE then RunExit will search for loaded modules with C:\SC2K4WIN contained within the path.

Matching is disabled when the launched application is located on the root of the drive (ie. C:\MYGAME.EXE) because it may match too broadly (ie. false positives). Additionally, any module with \WINDOWS\ in the path is automatically ignored.

Changing Matching Behaviour

The default configuration will work for the majority of applications, but there are additional customisation options which can be used to further extend support for specific applications. For example, if a launched application switches execution to a module running from a CDROM the default matching behaviour would not detect this because the paths will not match.

Match Any Loaded Module

Using the parameter /matchall will prevent RunExit from exiting Windows until all non-system modul

Related Skills

View on GitHub
GitHub Stars11
CategoryDevelopment
Updated29d ago
Forks1

Languages

Pascal

Security Score

95/100

Audited on Mar 5, 2026

No findings