Advice on my simple code please

Here's part of my update script that I use to update the FE on clients machines. It kills any running instances of MS Access that it finds on the target machine. If your IT guys have it all locked down this might not work either, and probably you'll have to point it at other machines besides localhost.

But if I needed to kill Access at a particular time of day, I would run something like this as a scheduled task under windows . . .
Code:
  Set service = GetObject("winmgmts:{impersonationLevel=impersonate}!\\localhost\root\cimv2")
  Set procs = service.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'msaccess.exe'")
  Do while procs.Count > 0
    WScript.Sleep 500
    i = i + 1
    Set procs = service.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'msaccess.exe'")
    if i > 20 then 
      For Each proc In procs
        proc.Terminate
      Next
    End If
  Loop
 
CanadaUser

And having made all users quit out of open sessions, you will of course always be the first person in the next day.

Take the advice in the previous post and have users opening a copy on their own PCs. I maintain version numbers in a table on the back end, and in the front end. Any difference in version numbers (because of an update when you're ready) will prompt the users into downloading the updated version.
 
Are you guys under the assumption that I have the users working from the mdb file?
I save it as ACCDE for the users and they stay out of my mdb file.

Any time the ACCDE file closes it automatically saves the record. Any forms with code that asks if the users want to save however, I'm unsure about.
As far as I'm concerned... if they lose data they simply have to enter it again.
The type of data they're entering is something they would notice. Most of the users only pull reports. :)

I might just leave it open with a dirty record as a test just to see what happens.

MarkK: I'm going to add your code to my list of options as having the db close at 2AM is just a work around until I find something I can work with. I have a few possibilities from wonderful people on this site, but simply haven't had the time to figure them out yet.

Cronk: Actually, I am the first person in each day. On occassion, there's another person or two, but it's easy to ask them to close it for a moment. It's not easy to figure out who on night shift left it open, which is what I'm dealing with now.

Loving the responses :)
 
Are you guys under the assumption that I have the users working from the mdb file?
I save it as ACCDE for the users and they stay out of my mdb file.

Doesn't change my opinion that they shouldn't share a file.
 
The code provided by @pr2-eugin worked beautifully. The file was closed each morning when I came in.
Also, you guys may be interested in a file given to me by @TimW. It can be found in my post [Solved] Identify users with db open. The file is called "Remote Close". I've added that to my db as well so I can kick everyone out any time I need. :)
 
I set it up the night before last. Just figured I'd let it do it's thing a couple of times before confirming. :)
 

Users who are viewing this thread

Back
Top Bottom