The Enhanced Write Filter is also shipped with Windows Embedded Standard 7. However it does not include the Disk mode known from earlier Embedded versions. The Disk Mode allowed to save all the changes on a separate hard drive.

There is an alternative approach available to create a scenario similar to the EWFs Disk Mode – you can use VHDs.
Because Windows 7 and also WES7 support to boot from VHDs (Virtual Hard Disks) you can make use of the differential VHD feature.
This feature allows you to create one master VHD file containing the operating system in the state it should stay and a differential VHD which stores all the changes made to the master image during runtime.

image (3)

For example you can have your Master VHD file on a Compact Flash and the differential file on a hard disk to redirect all the writes away from the flash media.

One feature from EWF is to discard all changes made to the image on every reboot.
The solution for this is to create a new differential VHD file with the master as parent and use the new VHD as default boot entry.
After a reboot the system is back in its original state.

Reset Differential VHD

To automate this process you can use the following batch file. Please adapt the paths to your VHD location in the “Variables” section. Have a look below for the installation of the batch file.

How it works

The system works with 2 differential VHD files which will be swapped out on every boot.
On each boot the batchfile checks which differential VHD is active.
It will then delete the non-active differential VHD and recreates the non-active VHD.
By this all previous changes are undone. Then the batchfile will set the new non-active VHD as new default boot device.
On the next start the system will boot from the fresh created VHD.

Batch File

 

@echo off
echo VHD Diff Resetter created by Wolfgang Unger

REM #########################
REM Variables
REM #########################
set VHD_Drive=D:
set VHD_Parent=wes7.vhd
set VHD_DiffFile1=wes7diff1.vhd
set VHD_DiffFile2=wes7diff2.vhd

set TempFile=D:\diskpart.txt
REM #########################

REM Try to delete the second diff file. if successful image 1 is bootet.
del %VHD_Drive%\%VHD_DiffFile2%
if exist „%VHD_Drive%\%VHD_DiffFile2%“ goto File2

del %VHD_Drive%\%VHD_DiffFile2%

echo create vdisk file=%VHD_Drive%\%VHD_DiffFile2% parent=%VHD_Drive%\%VHD_Parent% > %TempFile%
echo exit >> %TempFile%

diskpart /s %TempFile%

bcdedit /set {current} device vhd=

[%VHD_Drive%]\%VHD_DiffFile2%
bcdedit /set {current} osdevice vhd=[%VHD_Drive%]\%VHD_DiffFile2%

GOTO Done
:File2

del %VHD_Drive%\%VHD_DiffFile1%

echo create vdisk file=%VHD_Drive%\%VHD_DiffFile1% parent=%VHD_Drive%\%VHD_Parent% > %TempFile%
echo exit >> %TempFile%

diskpart /s %TempFile%

bcdedit /set {current} device vhd=[%VHD_Drive%]\%VHD_DiffFile1%
bcdedit /set {current} osdevice vhd=[%VHD_Drive%]\%VHD_DiffFile1%

:Done

del %TempFile%
echo Done.

Installation

  1. Install Windows Embedded Standard 7 to a VHD. Please have a look here for instructions.
  2. Boot the image.
  3. Save the batchfile from above to the image.
  4. Open Task Scheduler
  5. Click “Create Task…”
  6. Enter a name for the task and check “Run with highest privileges”
  7. Goto the “Triggers” tab an click “New”
  8. Select “At startup” from the “Begin the task” dropdown and click “OK”
  9. Goto the “Actions” tab and click “New”
  10. Browse to the batch file and click ok
  11. Click OK to save the task
  12. Run the batch file once and reboot

 

Usage Scenarios

This solution can be helpful when

  • using a flash disk drive which contains the master image and all changes should be located on a hard disk drive
  • changes should persist on reboots (for this do not create the task and execute the batch file only when needed)
  • you do not want to use EWF or FBWF
  • etc.