删除磁盘的时候应该先卸载磁盘才能删除,也就是说你执行closemedium之前要用storageattach移除磁盘。示例代码:

storageattach "VM1" --storagectl "IDE" --port 0 --device 1 --type hdd --medium none --mtype normal
closemedium disk "D:\Program Files\VM\VM1\VM1-disk2.vmdk" --delete

Related Posts: VirtualBox-cannot be closed because it is still attached to 1 virtual machines解决办法 :