Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    3

    Unanswered: Running DOS batch files

    Anyone have any leads for this problem?

    I'm trying to run a simple DOS batch file from within an Access macro. The batch file simply erases a TXT file (if it exists) from one network location, copies a second ascii file from a different network location to the first location, then renames the resulting copied file. (It's a kludgey refresh routine; there are a bunch of reasons for doing it this way.)

    The problem I have is that the batch file runs funny from within Access. Outside of Access, I can run it as many times as I want with no trouble. Within Access, the batch file chokes on its first task (the erase command) with the error message:

    "The process cannot access the file because it is being used by another process."

    As far as I'm aware -- and I've checked -- the file is being used by NO other process. Access is seeing something I don't see. Anyone know what it's seeing?

  2. #2
    Join Date
    Aug 2003
    Posts
    3

    Putting it another way...

    The problem seems related to differences in the way batched DOS commands are handled between:

    1) running the batch file by double-clicking on it; and,
    2) shelling out to the batch file from an Access macro using the RunApp action.

    In the first instance, the way my machine is configured I can run that delete/copy/rename sequence all day long under any conditions and it seems to work.

    In the second instance, Access usually produces a situation where the file-to-be-deleted behaves as if it were in-use by some other process and the delete chokes. Thus the entire kludgey refresh process chokes. Sometimes it works properly, I know not why, although I think it might be true that it runs properly once and then chokes every time thereafter.

    The file is NOT in-use by any other user; I'm the only one running this stuff right now, it's in development.

    My current thinking is that Access must generate some kind of DOS environment that differs from the one I generate by running

  3. #3
    Join Date
    Sep 2003
    Location
    Lancashire, UK
    Posts
    22
    Have you tried running the batch file using the shell function in a VBA module???

    Is Access using any of the files involved in the batch job prior to running the batch job??? Access may have a file still open at the time the job runs

    Is Access using any of the files after the batch job runs??? When an app is launched using RunApp action or Shell function, Access does not wait for control to return to it from the app, but will continue to run the rest of the code/macro simultaneously. Therefore Access may be doing something with a file before the batch job has chance to do its thing with it
    Last edited by Robbo; 09-24-03 at 07:28.

  4. #4
    Join Date
    Aug 2003
    Location
    SW Ohio
    Posts
    198
    Originally posted by Robbo
    Have you tried running the batch file using the shell function in a VBA module???

    Is Access using any of the files involved in the batch job prior to running the batch job??? Access may have a file still open at the time the job runs

    Is Access using any of the files after the batch job runs??? When an app is launched using RunApp action or Shell function, Access does not wait for control to return to it from the app, but will continue to run the rest of the code/macro simultaneously. Therefore Access may be doing something with a file before the batch job has chance to do its thing with it
    My best suggestion is to make a function similar to this and put in parameter calls if you have to work from macro as opposed to VBA modules. Lot cleaner. Plus the filecopy will wait until the prior transaction is done.


    If Dir(HomePath & !File_Name) = !File_Name Then
    DestPath = "T:\Private\IS\MServFTP\DLINFIL"
    If Dir(DestPath) = "'DLINFIL."" Then
    Kill DestPath
    End If
    FileCopy HomePath & !File_Name, DestPath
    Jim P.

    Supoorting Oracle, MSSQL7, Sybase 8, & Pervasive. Confusion Reigns

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •