Outra maneira é anexar no nível de serviço. Você precisa instsrv.exe e srvany.exe do Windows Resource Kit Tools. Coloque-os em qualquer pasta com os seguintes arquivos:
disk-W-install-permanently.cmd
@echo off
echo RUN THIS AS ADMINISTRATOR!
pause
cd %~dp0
copy srvany.* c:\windows\system32\
copy srvany-attach-disk-W c:\windows\system32\
instsrv disk_W_attach "c:\windows\system32\srvany.exe"
regedit disk-W-install-permanently.reg
pause
disk-W-install-permanently.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\disk_W_attach\Parameters]
"AppEnvironment"=""
"Application"="c:\windows\system32\cmd.exe"
"AppParameters"="/c srvany.bat"
"AppDirectory"="C:\Windows\System32"
srvany.bat
@echo on
set log=%temp%\srvany.log
echo log: Running at %date% %time% >>%log%
diskpart /s srvany-attach-disk_W >>%log%
net stop disk_W_attach
srvany-attach-disk-W
select vdisk file=”D:\private\vm\HDD\disk_W.vhd"
attach vdisk
exit
dir / b
disk-W-install-permanently.cmd
disk-W-install-permanently.reg
instsrv.exe
srvany.bat
srvany.exe
srvany-attach-disk-W
Agora edite o script srvany-attach-disk_W para apontar para o seu VHD, execute disk-W-install-permanently.cmd com privilégios de administrador e reinicialize.
É tudo!