@ECHO off REM VHD_Mount is edited English version of chenall's VHD_MNT batch for Win7 32/64 bit. REM It adds 2 shell commands to Registry: "Attach/Detach VHD" and REM "Create Dif VHD". To attach or detach a VHD, doubleclick its file. REM To Create a Dif VHD, select this command from RMC. The child VHD will be REM created in parent's directory and assigned relative to the parent name. REM If adding shell commands to "HKCR\.vhd\shell..." doesn't work for you, REM since Windows Virtual PC is installed on your PC, replace in :install and :uninstall REM sections "HKCR\.vhd\..." with "HKCR\Windows.VirtualPC.HD\..." in all commands IF "%~n1"=="" GOTO :install SET "diskpart=echo exit|%ComSpec% /k prompt %%dsc%%$_|diskpart" IF %2==PARENT GOTO :PARENT :attach TITLE Autodetect.... SET dsc=list$Svdisk %diskpart%|find /i "%~1" > nul && goto :detach TITLE Attach VHD %* SET dsc=select$Svdisk$Sfile="%~f1" $_attach$Svdisk$S%2$_ GOTO :diskpart :detach TITLE Detach VHD %* SET dsc=select$Svdisk$Sfile="%~f1"$_detach$Svdisk$_ GOTO :diskpart :PARENT SHIFT /2 FOR /l %%i in (1,1,99) do IF not EXIST "%~dpn1_dif%%i.vhd" (set "file=%~n1_Dif%%i.vhd" & GOTO :create) EXIT /b :create TITLE Create Dif VHD from Parent %1 echo. echo. VHD_MNT will create a Differencing VHD Image File echo. from Parent: %1 rem echo.Enter below a new Dif VHD file name, for example: %file% rem echo. Note: don't enter full path. echo. rem SET /p file=Enter new Dif VHD name: SET dsc=create$Svdisk$Sfile="%~dp1%file%"$SPARENT="%~f1"$_ TITLE Created Dif VHD %file% :diskpart %diskpart% rem PAUSE EXIT /b :install reg query "HKCR\.vhd\shell\Attach/Detach VHD\command" /ve 1>nul 2>nul && GOTO :uninstall reg add "HKCR\.vhd\shell\Attach/Detach VHD\command" /t REG_EXPAND_SZ /d "%%SystemRoot%%\system32\vhd_mnt.cmd \"%%1\"" /f >nul reg add "HKCR\.vhd\shell\Create Dif VHD\command" /t REG_EXPAND_SZ /d "%%SystemRoot%%\system32\vhd_mnt.cmd \"%%1\" PARENT" /f >nul reg add "HKCR\.vhd\DefaultIcon" /t REG_EXPAND_SZ /d "%%SystemRoot%%\system32\shell32.dll,8" /f >nul COPY /y "%~f0" "%SystemRoot%\system32\vhd_mnt.cmd" >nul echo. echo. VHD_Mount has been installed. echo. echo. Now you can doubleclick a VHD file to Attach/Detach, echo. or Create a Differencing VHD from selected Parent VHD echo. echo. Based on VHD_MNT by chenall 2011-04-29 echo. http://chenall.net/post/vhd_mnt PAUSE EXIT :uninstall echo. reg delete "HKCR\.vhd\shell" /f >nul DEL /f "%SystemRoot%\system32\vhd_mnt.cmd" echo. echo. VHD_Mount has been uninstalled. echo. echo. Based on VHD_MNT by chenall 2011-04-29 echo. http://chenall.net/post/vhd_mnt PAUSE EXIT