|
本帖最后由 小吴 于 2024-9-22 15:01 编辑
右键创建、加载、卸载VHD完美方法
在批处理论坛看到大神的代码,搬过来分享一下,在此作个记号留个脚印。
特点:
不需要批处理文件名本身,更没有批处理文件的路径,仅存在批处理的命令行。
下载或复制后直接导入注册表即可。
(适用于win7及以上,不适用于XP系统)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Vhdproject]
"icon"="%SystemRoot%\\system32\\shell32.dll,7"
"MUIVerb"="VHD工具"
"SubCommands"="CreateExpandableVHD;CreateFixedVHD"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\Vhdproject]
"icon"="%SystemRoot%\\system32\\shell32.dll,7"
"MUIVerb"="VHD工具"
"SubCommands"="CreateExpandableVHD;CreateFixedVHD"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\CreateExpandableVHD]
"icon"="%SystemRoot%\\system32\\shell32.dll,7"
"MUIVerb"="创建动态VHD"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\CreateExpandableVHD\command]
@="cmd.exe /v:on /c color 1F & set /p \"vhdName=请输入文件全称(例123.vhd或123.vhdx):\" & set /p \"vhdSize=请输入文件大小(不必录入MB,直接例5000):\" & set \"vhdPath=%V\\!vhdName!\" & set \"vhdPath=!vhdPath:\\\\=\\!\" & echo,!vhdPath! & cmd.exe /v:on /c \"echo create vdisk file=\"!vhdPath!\" maximum=!vhdSize! type=EXPANDABLE & echo Select vdisk file=\"!vhdPath!\" & echo attach vdisk & echo create partition primary & echo select partition 1 & echo ASSIGN & echo format fs=ntfs label=!vhdName! quick\" | diskpart.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\CreateFixedVHD]
"icon"="%SystemRoot%\\system32\\shell32.dll,7"
"MUIVerb"="创建固定VHD"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\CreateFixedVHD\command]
@="cmd.exe /v:on /c color 1F & set /p \"vhdName=请输入文件全称(例123.vhd或123.vhdx):\" & set /p \"vhdSize=请输入文件大小(不必录入MB,直接例5000):\" & set \"vhdPath=%V\\!vhdName!\" & set \"vhdPath=!vhdPath:\\\\=\\!\" & echo,!vhdPath! & cmd.exe /v:on /c \"echo create vdisk file=\"!vhdPath!\" maximum=!vhdSize! type=FIXED & echo Select vdisk file=\"!vhdPath!\" & echo attach vdisk & echo create partition primary & echo select partition 1 & echo ASSIGN & echo format fs=ntfs label=!vhdName! quick\" | diskpart.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AllFilesystemObjects\shell\KLoadvhd1]
"icon"="%SystemRoot%\\system32\\shell32.dll,7"
@="右键加载VHD √"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AllFilesystemObjects\shell\KLoadvhd1\command]
@="cmd.exe /v:on /c color 1F & (echo Select vdisk file=%1 & echo attach vdisk & echo select partition 1 & echo assign) | diskpart"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AllFilesystemObjects\shell\LKillvhd1]
"icon"="%SystemRoot%\\system32\\shell32.dll,7"
@="右键卸载VHD ×"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AllFilesystemObjects\shell\LKillvhd1\command]
@="cmd.exe /v:on /c color 1F & (echo Select vdisk file=%1 & echo detach vdisk) | diskpart"
|
评分
-
查看全部评分
|