Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make mde check for an updated version??

Status
Not open for further replies.

Hfnet

IS-IT--Management
Dec 31, 2003
369
GB
I want to have a local copy of an mde on each machine, it's linked to SQL server and Oracle.

I would like it to check each time to see if there is an updated version of the mde, and if there is, to copy it locally.

I will obviously need a local table in the mde with the version number, and a linked table to compare against, but how do I get the database to copy the updated version to the same folder and restart itself? I have use of visual studio .net if necessary, but am new to that.

Thanks

Ask not what you can do for your boss, ask how much it's worth.
 
I don't know how to get an mde to delete itself and replace itself. It's easier if you introduce a third "loader" program into the system. This is a simple program that compares the two version numbers, downloads a new mde if needed, then starts the local mde.

Geoff Franklin
 
I don't want to use a batch file, i'd rather use a vb script.

I have this script, but it does not seem to launch the new file:

Code:
Option Explicit
Dim oArgs, ArgNum
Dim oFS, oFileSource, oFileTarget, oSh
Dim ArgA, ArgB, ArgC
Dim strComputer
Dim objWMIService
Dim colProcesses, objProcess
Dim TimerStart, StillRunning

Set oArgs = WScript.Arguments
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
Set oSh = WScript.CreateObject("WScript.Shell")

If oArgs.Count<>3 Then
 Call DisplayHelp
End If 

ArgA = oArgs(0)
ArgB = oArgs(1)
ArgC = oArgs(2)

If Not IsNumeric(ArgA) Then
  Call DisplayHelp
End If

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

TimerStart=Timer
StillRunning=True
While (StillRunning And Timer<=TimerStart+4)
  Set colProcesses = objWMIService.ExecQuery _
      ("Select * from Win32_Process Where ProcessID = " & ArgA)
  StillRunning = (colProcesses.Count<>0)
Wend

If StillRunning Then
  MsgBox "Timeout waiting for old Application to terminate"
  WScript.Quit 1
Else
  Set oFileSource=oFS.GetFile(ArgB)
  Set oFileTarget=oFS.GetFile(ArgC)
  oFileSource.Delete
  oFileTarget.Move (ArgB)
  'MsgBox "Update was successful. Press OK to continue"
	oSh.Run """" & oFileTarget.Path & """"  
  WScript.Sleep 100
  WScript.Quit 0
'End If

Sub DisplayHelp()
 WScript.Echo "About this script:" &  chr(13) &_
        "updater {oldfileprocess} {oldfile} {newfile}" &  chr(13) &_
 WScript.Quit -1
End Sub

The mde checks to see if it the latest one against the two tables, and if not it copies over the new mde as xxx.mde.new, and the mde closes.

This script is then called to delete the mde and rename the mde.new to .mde and then launch it, but that seems to be where the thing breaks down...

Ask not what you can do for your boss, ask how much it's worth.
 
It's called from the mde prior to the mde closing via a DoCmd.Quit command.

That is why the code above is checking to see that the mde has closed...

Ask not what you can do for your boss, ask how much it's worth.
 
Well,

It seems that when closing the mde your script is terminated also.

Instead of letting the mde decide what to do, why not let your script do that? Can't you create an .exe from it that checks if the right mde is available and if not, copies before starting it up? Better for the users also, only one time to startup their program.

I have no experience with vbscript or compiling it into an exe, but it can't be to hard to find out (I'm interested if you do!). If it doesn't work - I use the batch solution, which works fine. Only once in the last 2 years did somebody accidently erase the batch file - no real trouble. It is being used by about 150 people - every day.

EasyIT

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top