Start a task when ms access is closed

Birn 21 Reputation points
2022-12-19T11:28:56.63+00:00

Hello,

first of all: I've been looking for a suitable solution for a few hours, but unfortunately I haven't really found any :-(

I would like to start a task from taskscheduler as soon as the MS ACCESS application is closed.
There is event 300, but it is always written when an Office application is "started" and is therefore omitted. I did not find a special event when ending Access :-(
I therefore believe that this is not possible, right? But that would be the nicest solution, also for the user, since he could then start Access from anywhere.

However, an alternative would be a batch file.
That's ugly, but if there's no other way...
But even here I still despair a little.
Actually it should be about this:

@echo off  
"C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE"  
"C:\Program Files\FreeFileSync\FreeFileSync.exe" C:\Users\xxx\Documents\Backup.ffs_batch  

However, the cmd window always remains open in the background :-( Is it possible to make it "invisible" somehow?
It would be even nicer if you could also place it on the taskbar so that the user can start it directly from there, but unfortunately I couldn't find anything about that either :-(

Thank you. And mercy if I just couldn't find what I was looking for despite searching.

greetings
Björn

PS: Using W11-Home with MS365.

Microsoft 365 and Office Access Development
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,291 Reputation points
    2022-12-19T18:08:00.97+00:00

    Use a Powershell .ps1 file to launch Access. As an example, name it Launch.ps1.

    Start-Process -wait  "C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE"  
     "C:\Program Files\FreeFileSync\FreeFileSync.exe" C:\Users\xxx\Documents\Backup.ffs_batch  
    

    Then in the bat file, have it launch Powershell with a hidden window pointing to the launch script.

    start powershell.exe -WindowStyle Hidden -file c:\scripts\launch.ps1  
    

    When you run the bat file, the command prompt window will briefly appear, launch Powershell and then go away.

    The PS window will be hidden and launch MSAccess and wait for it to terminate. Then it will run your sync tool.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.