Skip to content

Instantly share code, notes, and snippets.

@DiegoQueiroz
Created August 10, 2014 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DiegoQueiroz/1a645df98e2b7004b09c to your computer and use it in GitHub Desktop.
Save DiegoQueiroz/1a645df98e2b7004b09c to your computer and use it in GitHub Desktop.
@echo off
@cls
set tempfile="%TEMP%\diskscrp.dsk"
echo.
echo === Disk removal tool ===
echo.
echo Select the disk volume number
echo (if the disk has multiple volumes, select any of them)
echo.
echo list volume | diskpart | findstr /C:Volume /C:---
echo.
set /p volume=" Selected volume: "
echo.
echo select volume %volume% >>%tempfile%
echo offline disk >>%tempfile%
echo online disk >>%tempfile%
diskpart /s %tempfile% | findstr /C:"not valid"
if "%ERRORLEVEL%"=="1" (
echo Disk has been unlocked successfully. Try to safely remove it now.
)
del /F %tempfile%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment