You shouldn't use VHD for this. For a read-only image simply use ISO. Windows already has built-in capability to mount ISO files for a long time
There are many ways to convert a folder to ISO so just burn the VHD's content to ISO file and distribute it
It was claimed that an IMG file can also be used for disc images although I don't know exactly which IMG format is supported and there's no official documentation about that either
Modern Windows also supports other image formats like WIM and FFU. I think they can also be used. For details you can checkout What is the most efficient, native way to image a Windows partition?
When creating a WIM file you can use /CheckIntegrity so that Windows detects issues with the files when mounting. So you can convert the VHD to a WIM easily with a command, for example
Dism /Capture-Image /ImageFile:C:\data\my.wim /CaptureDir:C:\vhd\mounted\path /Name:MyData
You can also use the /Split-Image option to make a read-only image although it won't be a single file
For WIM, this command splits an existing .wim file into multiple read-only split .swm files.
In older Windows you can also use imagex /split to achieve the same
For FFU similarly there's also the /Split-FFU option for a multiple-part read-only image
Anyway if you really want to use a VHD file you can mark each partition in the VHD image read-only. This won't ensure that the signature of the VHD won't change but each volume's content should be basically unchanged
- Switch off "automount" by running
mountvol.exe /N
- Connect disk to Windows (do not mount the disk)
- Run
diskpart
- Enter
list volume
- Enter
select volume X
(where X is the correct volume number from the previous command)
- Enter
att vol set readonly
- Enter
detail vol and ensure the read-only bit is set
How to make a partition on external storage read-only? And revert to normal?
This works with native Windows filesystems like NTFS or ReFS only
An alternate solution is to create read-only UDF partitions in the VHD image. The UDF formatter in Windows is very limited so you should use a 3rd party solution. For example with mkudffs you can specify --media-type=cd or --media-type=dvd to mark the FS as read-only. Despite being a universal filesystem, making a truly universal UDF on a non-optical medium is tricky so check this for a better script to format UDF