In tip 5955, I used the RSM VIEW command to determine if a tape was inserted in a tape drive.
Using rsm view /cgC888E08900454C4C956DF84868C17C78 /TPhysical_media, where C888E08900454C4C956DF84868C17C78 is the GUID of my tape library, the following commands set the media variable to the Physical_Media id of the mounted tape:
set media= for /f "Skip=2 Tokens=*" %%a in ('rsm view /cgC888E08900454C4C956DF84868C17C78 /TPhysical_media') do if not "%%a"=="The command completed successfully." set media="%%a" if not defined media goto notapeYou can use the Partition Id with the Deallocate command.
To determine the Partition Id and issue a Deallocate:
set partition=%media: - 1=%
rsm.exe deallocate /PF%partition%