Download TAPEUTIL, a Win32 console application which can detect if media is in your drive, and optionally eject or retention it (if the drive supports ejection and/or retentioning).

The TAPEUTIL.TXT file contains:

TAPEUTIL 1.2                              (C) 2004 by Bill Stewart (                              LICENSE AGREEMENT                              This program is provided as copyrighted freeware. You are free to use it in any                              environment without payment to the author.                              DESCRIPTION                              In investigating the Windows 2000/XP/Server 2003 ntbackup program to perform                              backups, I noticed that you can retension a tape from the ntbackup GUI, but                              there is no command-line equivalent. Hence TAPEUTIL.EXE.                              TAPEUTIL is a Win32 console (command-line or text-based) program that can:                              *   Detect if a tape is inserted                              *   Eject the currently inserted tape (if supported)                              *   Retension the tape (if supported)                              SYNTAX                              TAPEUTIL \[-e | -r\] \[-q\] drive_number                              -e              Eject the media from the drive.                              -r              Retension the media in the drive.                              -q              Run quietly (no output).                              drive_number    The number of the tape drive, numbered 0 through 9.                              EXIT CODES                              0       No error.                              1       Incorrect function.                              6       Unable to open the specified drive.                              21      The device is not ready.                              50      The request is not supported.                              120     Requires Windows NT 4.0 or later.                              1109    Unable to unload the media.                              1110    The media in the drive may have changed.                              1112    No media in drive.                              For other errors, use NET HELPMSG followed by the error number (Windows 2000                              and later only).                              Here are some common causes for the errors:                              1       The tape drive in this machine does not support retensioning.                              6       Invalid drive number specified.                              21      The drive is in an "eject" state but the media has not been removed.                              1110    The drive is still loading newly inserted media.                              VERSION HISTORY                              1.2 (28 Apr 2004):                              *   Added -e (eject) option.                              *   Improved Win32 error handling.                              1.1 (15 Apr 2004):                              *   Changed exit codes to match Win32 error codes, and implemented better error                                  handling.                              1.0 (13 Apr 2004):                              *   Initial version.