Hacking 'Repeatable Save State Restore' into Virtual PC

Hacking 'Repeatable Save State Restore' into Virtual PC

Rate This
  • Comments 4

One feature that people regularly ask for in Virtual PC is the ability to have a virtual machine in a 'saved state' and to then be able to repeatedly restore the virtual machine from that saved state.  This is particularly useful for training and demonstration environments.  Unfortunately - we have never implemented support for this functionality directly - but it is fairly easy to setup with a few tweaks, as follows:

  1. Setup your virtual machine the way you want it
  2. Enable undo disks
  3. Get the virtual machine to the stage that you want to repeatedly restore from
  4. Close the virtual machine and select to 'Save state and save undo disks' - as well as checking the option to commit the undo disks
  5. Open the virtual machine settings and go to the close settings and select to 'Automatically close without a message and: Turn off and delete changes'

    Now it gets a little tricky.
  6. Go to the location where your .VMC is stored (usually in the 'My Virtual Machines' folder in 'My Documents')
  7. There should be a .VMC and .VSV file - these are the configuration and saved state files
  8. Create a subfolder called 'Backup' and copy these two files into it
  9. Now make a new .CMD file with the following contents:

    @ECHO OFF
    copy .\Backup\. . /y > nul
    start "" "C:\Program Files\Microsoft Virtual PC\Virtual PC.exe" -startvm "F:\Ben's Documents\My Virtual Machines\Windows 98\Windows 98.vmc"

    (substituting the name and location of the .VMC file with your .VMC file)
  10. You can now start the virtual machine by running this .CMD file - and it will always start from the saved state you made in step 4.

A couple of notes:

  1. The '@ECHO OFF' and ' > nul' commands are used to stop any text from being displayed by the .CMD file when it runs
  2. The 'start ""' command is used to allow the .CMD window to close as soon as the virtual machine is started
  3. You need to use the full path for the .VMC file - otherwise you will get an error message from Virtual PC - complaining about duplicate virtual machine names.
  4. The .CMD file should only be three lines long - but the last line is very long - and will probably be wrapped on the post.

Cheers,
Ben

Leave a Comment
  • Please add 8 and 3 and type the answer here:
  • Post
  • Nice tip.

    It would be nice to see a post on all the command line options for VirtualPC... when I had a look it seemed a little empty and didn't mention the -startvm option.

    - Andy
  • I was trying to figure this out yesterday too! The only day I didn't scan the msdn blogs. Thanks and keep the tips coming!!!

    -craig
  • Hi Andy,

    If you go to the Virtual PC help index and enter 'command line, reference' you should get all the information about the command line options. There are no undocumented options.

    Cheers,
    Ben
  • It works!  Thanks a bunch.

    I'm actually using this to play games on win98 then restore if I die.  :P

Page 1 of 1 (4 items)