However, using a script to take the disk offline and bring it online did not remove the read-only attribute. After a bit more digging, I found a command that works like a charm. I had to change the disk attributes and clear the read-only flag.
The full PowerShell script, which I call from the c:\Windows\setup\scripts\setupcomplete.cmd file, is shown below.
$script = $Null
$script = @"
select disk 1
online disk noerr
attributes disk clear readonly
"@
$scriptdisk += $script + "`n"
$scriptdisk diskpart
echo E: %{$a = mountvol $_ /l;mountvol $_ /d;$a = $a.Trim();mountvol Z: $a}
I don't know if the read-only problem comes from sysprep, changing drive letters, a VMware thing, or what. Since the script is executed during the sysprep process, you never know what is going on behind the scenes. Drive letters get changed and the D drive is read-write, just as you'd expect.
Derek, I've just recreated this issue accidentally and found that if I just bring the disk on-line using DISKPART, the disk appears as Read-Write but if I first bring the volume on-line followed by the disk then it is Read-Only. Interesting...
ReplyDelete