Issues with Batch Taskkill of Parent MSAccess Process

泄露秘密 提交于 2019-12-12 17:53:23

问题


Process Tree:

I have an MS Access version control macro that checks users current file version on open, and if not up-to-date, the macro launches a batch file that 1) should delete their current file, and then 2) copies the up-to-date front-end version from the network and pastes it on their local system.

My issue:

Everything works EXCEPT for the deletion of the users original file. Since this file is the parent process of the batch file I haven't found a way to Kill the task so it can be deleted.

Current Code:

TASKKILL /F /fi /IM MSACCESS.EXE /T

del "%originalFile%"

**I thought maybe I was having issues because the batch was a child of the Access process, so I've also tried with no luck:

TASKKILL /F /fi /IM MSACCESS.EXE

I always get the error:

ERROR: Invalid syntax. Value expected for '/fi'.

Its been a long day, so I assume I'm missing something simple and would love an extra set of eyes. Any help would be greatly appreciated!


回答1:


I have a similar setup, but without TASKKILL.

Directly after launching my update batch, I do Application.Quit

' If need to update
Shell UPDATE_BATCH, vbNormalFocus
Application.Quit

And in the update batch, I wait for 3 seconds so that Access has enough time to exit (and release the lock on the frontend).

sleep.exe 3
REM ... copy new frontend ...
sleep.exe 1
REM ... start MSACCESS command line ...

How to "sleep"? See here: SLEEP.exe (2003 Resource Kit) for different variants.



来源:https://stackoverflow.com/questions/33781749/issues-with-batch-taskkill-of-parent-msaccess-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!