Created
May 20, 2023 04:04
-
-
Save hui-shao/ae616b7922bf862f471f085b594a6b75 to your computer and use it in GitHub Desktop.
A script helps to compact vhd/vhdx.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if [%1]==[] ( | |
echo ========= 使用说明========= | |
echo 请将文件拖放到该批处理上。 | |
echo 按任意键退出... | |
pause>nul | |
exit /B 1 | |
) else ( | |
del /q DiskPart_compact_temp >nul 2>nul | |
echo select vdisk file="%1">>DiskPart_compact_temp | |
echo detach vdisk>>DiskPart_compact_temp | |
echo attach vdisk readonly>>DiskPart_compact_temp | |
echo compact vdisk>>DiskPart_compact_temp | |
echo detach vdisk>>DiskPart_compact_temp | |
echo attach vdisk>>DiskPart_compact_temp | |
start /wait diskpart /s DiskPart_compact_temp | |
del DiskPart_compact_temp | |
echo 运行完成,按任意键退出。 | |
pause>nul | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment