Link to home
Start Free TrialLog in
Avatar of ppdanila
ppdanila

asked on

DOS 'Lock' Command under Windows

Dear Experts:

  The DOS v.7.x 'Lock' command (that is supposed to lock whole drives to give direct access to files) seems to malfunction under Windows 95. Each time I attempt to use it Windows produces one and the same message 'Access is denied'.
Therefore I am looking for a small utility which would be able to enhance (or even replace) this lame Lock command. Do you, by any chance, know of such one? Any piece of advice will be highly appreciated.
Thank you. Respectfully,
PP
Avatar of Blood
Blood
Flag of United States of America image

Utilizing the "lock" and "unlock" command are highly questionable.  I say this only because of the huge possibility that you can corrupt the FAT.

If you need to use these programs (for instance to use the "undelete" command), you should do so while booted to a dos prompt.  What you want to avoid is the chance that another program (namely windows 95) will write to the drive while it is in the lock state.

You should not get the error if you boot to a dos prompt (or "Command Prompt Only" after the F8 command while booting).
Indeed do not use lock to write to your win9x disk, some people  use there d: disk  (or zip) for dos, dus that is OK.
Use LOCK <drive> <y in your autoexec.bat to constantly lock the disk
PS make a file called y with 'y' and 'return' key (chr13)
Avatar of ppdanila
ppdanila

ASKER

I cannot agree with that. In many cases we need to use the LOCK command from within Windows. I'll try to explain why.
  We know that Windows restricts a wide range of file
operations (like move, delete, rename, sometimes even view), especially when they are aimed at vitals. Still, in some special cases we need to override this protection. So - in idea - the Lock command must be able to "lock" disk drives from the Windows' protection giving us exclusive access to files, thus allowing any file operations by means of DOS commands (after that you can 'unlock' the previously locked drive and return to Windows' normal operation). That is why the LOCK and UNLOCK commands were introduced to newer versions of DOS (7.x).
  But in practice the Lock command is not executed properly: if you want to lock, say, drive C: (in order to replace a corrupted (vital) file with a good one, or temporarily disable a program by renaming its executable or DLL), Windows produces the message 'Access is denied'. So, to complete your repair you have to shut down Windows, restart in DOS mode, do your moving/ deleting/ renaiming and restart Windows again, which is extremely
cumbersome, isn't it?
  Therefore I am looking for some "work-around" for the Lock command: either an enhanced version of the command itself, or a small utility that can replace it and realize the same function.
 Any piece of advice would be highly appreciated. Thank You and Best Regards,
  PP
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Attn:. mark2150
Thank you. A accept the proposed answer. It sounds very convincing. In case, as you maintain, all emergency file operations must be done dropping down to DOS, the only thing I don't understand is why Windows' DOS v.7.x would need the LOCK and UNLOCK commands at all. What's the supposed purpose of them?
Respect,
PP
Windows does automatic disk cleanup. (Ever notice how sometimes it'll start hitting the disk really hard while you're just sitting there?) You also need LOCK even when at DOS mode to make the DOS UNDELETE function work right as it can't tolerate FAT updates while it's running.

M

Thank you. Now I will know.
PP