Lock and unlock commands

Updated: 11/12/2023 by Computer Hope
lock command

The lock and unlock commands allow or deny direct disk access for applications.

Availability

Lock and unlock are internal commands that are available in the following Microsoft operating systems.

Lock and unlock syntax

LOCK [drive:]
drive: Specifies the drive that needs to be locked.
UNLOCK [drive:]
drive: Specifies the drive that needs to be unlocked.

Lock and unlock examples

lock c:

Lock the C: drive

When typing the command above, you will receive the following prompt.

WARNING: The LOCK command enables direct access by programs that can CORRUPT file names and DESTROY disk data, resulting in the loss of files on your disk.
Are you sure (Y/N)?
unlock c:

Unlock the C: drive

Note

If an error is indicating that a process cannot continue because the hard drive is locked, the unlock command cannot resolve these error messages.