"Permission Denied" If SHELLed Process Accesses Same OPEN File (38071)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q38071

SUMMARY

"Permission Denied" normally occurs when you attempt to access a file that is locked by another process or attempt to write to a write-protected disk.

For example, if you OPEN a file, LOCK any record, then SHELL to another program that attempts to access the same file, a "Permission Denied" error properly occurs.

This information applies to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50 for MS-DOS; to Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2; and to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2.

MORE INFORMATION

The following program, which SHELLs to a copy of itself, correctly gives a "Permission Denied" error when run from an .EXE file or from within the QB.EXE or QBX.EXE editor (if you have first created TEST.EXE):

   TEST.BAS
   --------
   OPEN "TEST.DAT" FOR RANDOM AS #1
   LOCK #1, 3
   SHELL "TEST.EXE"
   UNLOCK #1, 3
   END
				
The following program also demonstrates "Permission Denied" if you attempt to run TEST.EXE from within the SHELL session, before giving the EXIT command to end the child process (session):
   OPEN "TEST.DAT" FOR RANDOM AS #1
   LOCK #1, 3
   SHELL          ' Before saying EXIT, run TEST.EXE to show the
   UNLOCK #1, 3   ' "Permission Denied" message.
   END
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB38071