Absolutely. This is generally used for testing purposes: before an author publishes a new release, they can automatically run a walkthrough and make sure the transcript matches what they expect.
Inform 6 games generally have this built-in as the REPLAY command (RECORD does the opposite and makes a list of commands entered); Inform 7 ones don’t any more, and I’m not sure why, but it’s not too hard to add back in.