Microsoft KB Archive/38071

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Knowledge Base


"Permission Denied" If SHELLed Process Accesses Same OPEN File

Article ID: 38071

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 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
                


Additional query words: QuickBas BasicCom

Keywords: KB38071