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:
- Setup your virtual machine the way you want it
- Enable undo disks
- Get the virtual machine to the stage that you want to repeatedly restore from
- Close the virtual machine and select to ‘Save state and save undo disks’ – as well as checking the option to commit the undo disks
- 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.
- Go to the location where your .VMC is stored (usually in the ‘My Virtual Machines’ folder in ‘My Documents’)
- There should be a .VMC and .VSV file – these are the configuration and saved state files
- Create a subfolder called ‘Backup’ and copy these two files into it
- Now make a new .CMD file with the following contents:
copy .Backup. . /y > nul
start “” “C:Program FilesMicrosoft Virtual PCVirtual PC.exe” -startvm “F:Ben’s DocumentsMy Virtual MachinesWindows 98Windows 98.vmc” (substituting the name and location of the .VMC file with your .VMC file)
- 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:
- The ‘@ECHO OFF’ and ‘ > nul’ commands are used to stop any text from being displayed by the .CMD file when it runs
- The ‘start “”‘ command is used to allow the .CMD window to close as soon as the virtual machine is started
- 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.
- The .CMD file should only be three lines long – but the last line is very long – and will probably be wrapped on the post.