The command you are looking for is:
dism /capture-image /imagefile:"f:\example.wim" /capturedir:C:\ /name:"C-Drive" /compress:max /verify /EA
Be sure to replace "F:\Example.wim" with the name of the WIM file you wish to create. Also, the /compress
, /verify
, and /EA
switches are optional. /compress
makes the WIM file smaller, /verify
double-checks to make sure the data was captured correctly, and /EA
also captures some NTFS metadata that's not normally present on the drive (such as alternate data streams or POSIX ACLs -- stuff that you can't really see or edit) but that some weird programs might use. All three make the capture process take longer but ensures that it's accurate, contains absolutely everything, and is as small as possible.
Also, this is best done by booting from WinPE or Windows boot media and capturing offline. Be aware when you do this, however, that your Windows partition may no longer be the C: drive at that point.