Skip to content

Instantly share code, notes, and snippets.

@a7md0
Created January 19, 2022 16:35
Show Gist options
  • Save a7md0/c128b3c84bc6e90ddf3c00bddd14aabd to your computer and use it in GitHub Desktop.
Save a7md0/c128b3c84bc6e90ddf3c00bddd14aabd to your computer and use it in GitHub Desktop.
Lock/unlock BitLocker encrypted drive script
@set DRIVE=%1
@manage-bde -status %DRIVE% | find "Lock Status:" | find "Locked" > nul2
@if "%ERRORLEVEL%"=="0" (
@manage-bde -unlock -pw %DRIVE%
) else (
@manage-bde -lock -ForceDismount %DRIVE%
)
@manage-bde -status %DRIVE% | find "Lock Status:" | find "Unlocked" > nul2
@if "%ERRORLEVEL%"=="0" (
@start "" "%DRIVE%"
)
Pass the drive letter as first parameter `BitLockerDrive.bat D:/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment