Any small script that implements fast mount and detach VHD files


If you want to put all the data in a dynamic VHD, attach it to Windows 7 when you need it, and then VHD when you need it in VPC. Separate from the Windows 7 system and then hang it on the VPC. In this way, any operation on both sides will directly affect the VHD, and it is not necessary to perform unnecessary copying operations.

After using it for a while, I found that the additional VHD is easy to use but it is very troublesome to operate. It must be reattached after each reboot. It must be separated in the system before hanging to the VPC. I can't stand it anymore. I have nothing to do at night. I wrote two small scripts for fast mount (attach) and separate VHD files:

Additional VHD scripts.cmd

=======Code Start ========

@echo off

echo select vdisk file= %VHD file path % >vhdsel

echo attach vdisk>>vhdsel

echo list disk>>vhdsel

diskpart /s vhdsel

del /f /q vhdsel


To separate the VHD script, just rewrite the attach vdisk command in the above code to detach vdisk.

The VHD file mounting function of Windows 7 system has been well received. Indeed, with the support of VHD, system administrators can greatly improve the work efficiency when deploying the environment (the first two days found a WIM to VHD tool, I am very surprised that combined with WAIK, custom Windows is just like playing...). In addition, in the Windows system environment, the VHD can be directly used as a disk mount. Personally, this function can be said to be epoch-making. Since RC, it has been paying attention to this information, but since I have not tried to really start using it, I still After RTM, it was gradually realized that it was convenient.

Copyright © Windows knowledge All Rights Reserved