I’m trying to write a batch script which unlocks a bitlocked drive. First, I’m trying to check if the drive is locked or not. So far, I’ve got:
:: Check if the drive is already unlocked
set unlockstatus=0
FOR /F "tokens=*" %%i IN ('manage-bde -status %inp%') DO (
echo %%i | find /c "Unlocked" | set /p found=
if %found%==1 set unlockstatus=1
)
if %unlockstatus%==1 (
echo This drive is already unlocked.
goto input
)
%inp% is a drive letter, followed by a colon.
For some reason, this straight up doesn’t work. It looks like for some reason piping input into the set command on the second line doesn’t work. Everything else seems to work OK. How can I accomplish this?
Use another for loop to parse the results of the find command.