Microsoft DOS lock and unlock command

Updated: 09/15/2017 by Computer Hope

About lock and unlock

Lock allows a user to lock a drive, enabling direct disk access for an application.

Unlock allows a users to unlock a drive, disabling direct disk access for an application


The lock command is an internal command that is available in the below Microsoft operating systems.

Windows 95
Windows 98

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 above command you will receive the below 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 errors is indicating that a process cannot continue because the hard drive is locked the unlock command cannot resolve these error messages.

Additional information

  • See our lock definition for further information and related links on this term.