DriveLock

Prevents the eject feature of the specified drive from working.

DriveLock Drive

Parameters

Drive

Type: String

The drive letter followed by a colon and an optional backslash (might also work on UNC paths and mapped drives).

Error Handling

An exception is thrown on failure, such as if Drive does not exist or does not support the locking feature.

Remarks

Most drives cannot be "locked open". However, locking the drive while it is open will probably result in it becoming locked the moment it is closed.

This function has no effect on drives that do not support locking (such as most read-only drives).

To unlock a drive, call DriveUnlock. If a drive is locked by a script and that script exits, the drive will stay locked until another script or program unlocks it, or the system is restarted.

DriveUnlock, Drive functions

Examples

Locks the D drive.

DriveLock "D:"